
;;;=============================================================================
;;;   DSM-5 Differential Diagnosis (DDD) Expert System
;;;   DSM-5鉴别诊断专家系统
;;;
;;;     The DDD expert system diagnoses mental disorder
;;;     problems of a person.
;;;     DDD专家系统诊断一个人的精神障碍问题。
;;;     参考文献：《DSM-5鉴别诊断手册》，Michael B. First，2016年3月，北京大学出版社。
;;;     Designed by OpenMinds, 2025, CLIPS Version 6.4
;;;     Email: 28485690@qq.com
;;;
;;;     To execute, merely load, reset and run.
;;;==============================================================================

(defmodule MAIN (export ?ALL))

(defmodule POOR-SCHOOL-PERFORMANCE (import MAIN ?ALL))

(defmodule BEHAVIORAL-PROBLEMS (import MAIN ?ALL))

(defmodule SPEECH-DISTURBANCE (import MAIN ?ALL))

(defmodule DISTRACTIBILITY (import MAIN ?ALL))

(defmodule DELUSIONS (import MAIN ?ALL))

(defmodule HALLUCINATIONS (import MAIN ?ALL))

(defmodule CATATONIC-SYMPTOMS (import MAIN ?ALL))

(defmodule ELEVATED-EXPANSIVE-MOOD (import MAIN ?ALL))

(defmodule IRRITABLE-MOOD (import MAIN ?ALL))

(defmodule DEPRESSED-MOOD (import MAIN ?ALL))

(defmodule SUICIDAL-IDEATION-BEHAVIOR (import MAIN ?ALL))

(defmodule PSYCHOMOTOR-RETARDATION (import MAIN ?ALL))

(defmodule ANXIETY (import MAIN ?ALL))

(defmodule PANIC-ATTACKS (import MAIN ?ALL))

(defmodule AVOIDANCE-BEHAVIOR (import MAIN ?ALL))

(defmodule TRAUMA-PSYCHOSOCIAL-STRESSORS (import MAIN ?ALL))

(defmodule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY (import MAIN ?ALL))

(defmodule EATING-BEHAVIOR (import MAIN ?ALL))

(defmodule INSOMNIA (import MAIN ?ALL))

(defmodule HYPERSOMNOLENCE (import MAIN ?ALL))

(defmodule SEXUAL-DYSFUNCTION-FEMALE (import MAIN ?ALL))

(defmodule SEXUAL-DYSFUNCTION-MALE (import MAIN ?ALL))

(defmodule AGGRESSIVE-BEHAVIOR (import MAIN ?ALL))

(defmodule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS (import MAIN ?ALL))

(defmodule SELF-INJURY-SELF-MUTILATION (import MAIN ?ALL))

(defmodule EXCESSIVE-SUBTANCE-USE (import MAIN ?ALL))

(defmodule MEMORY-LOSS (import MAIN ?ALL))

(defmodule COGNITIVE-IMPAIRMENT (import MAIN ?ALL))

(defmodule MEDICAL-CONDITIONS (import MAIN ?ALL))

;;****************
;;* DEFFUNCTIONS *
;;****************

(deffunction MAIN::choose-chief-complaint (?ccc)
   (switch (lowcase ?ccc)
   (case cc1 then
      (progn (assert (chief-complaint "不良学校表现"))
             (focus POOR-SCHOOL-PERFORMANCE)))
   (case cc2 then
      (progn (assert (chief-complaint "儿童或青少年中的行为问题"))
             (focus BEHAVIORAL-PROBLEMS)))
   (case cc3 then
      (progn (assert (chief-complaint "言语紊乱"))
             (focus SPEECH-DISTURBANCE)))
   (case cc4 then
      (progn (assert (chief-complaint "随境转移"))
             (focus DISTRACTIBILITY)))
   (case cc5 then
      (progn (assert (chief-complaint "妄想"))
             (focus DELUSIONS)))
   (case cc6 then
      (progn (assert (chief-complaint "幻觉"))
             (focus HALLUCINATIONS)))
   (case cc7 then
      (progn (assert (chief-complaint "紧张症症状"))
             (focus CATATONIC-SYMPTOMS)))
   (case cc8 then
      (progn (assert (chief-complaint "高涨或膨胀的心境"))
             (focus ELEVATED-EXPANSIVE-MOOD)))
   (case cc9 then
      (progn (assert (chief-complaint "易激惹心境"))
             (focus IRRITABLE-MOOD)))
   (case cc10 then
      (progn (assert (chief-complaint "抑郁心境"))
             (focus DEPRESSED-MOOD)))
   (case cc11 then
      (progn (assert (chief-complaint "自杀观念或行为"))
             (focus SUICIDAL-IDEATION-BEHAVIOR)))
   (case cc12 then
      (progn (assert (chief-complaint "精神运动性迟滞"))
             (focus PSYCHOMOTOR-RETARDATION)))
   (case cc13 then
      (progn (assert (chief-complaint "焦虑"))
             (focus ANXIETY)))
   (case cc14 then
      (progn (assert (chief-complaint "惊恐发作"))
             (focus PANIC-ATTACKS)))
   (case cc15 then
      (progn (assert (chief-complaint "回避行为"))
             (focus AVOIDANCE-BEHAVIOR)))
   (case cc16 then
      (progn (assert (chief-complaint "病因涉及创伤或心理社会应激源"))
             (focus TRAUMA-PSYCHOSOCIAL-STRESSORS)))
   (case cc17 then
      (progn (assert (chief-complaint "躯体主诉或疾病/外貌焦虑"))
             (focus SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY)))
   (case cc18 then
      (progn (assert (chief-complaint "食欲改变或异常的进食行为"))
             (focus EATING-BEHAVIOR)))
   (case cc19 then
      (progn (assert (chief-complaint "失眠"))
             (focus INSOMNIA)))
   (case cc20 then
      (progn (assert (chief-complaint "嗜睡"))
             (focus HYPERSOMNOLENCE)))
   (case cc21 then
      (progn (assert (chief-complaint "女性性功能失调"))
             (focus SEXUAL-DYSFUNCTION-FEMALE)))
   (case cc22 then
      (progn (assert (chief-complaint "男性性功能失调"))
             (focus SEXUAL-DYSFUNCTION-MALE)))
   (case cc23 then
      (progn (assert (chief-complaint "攻击行为"))
             (focus AGGRESSIVE-BEHAVIOR)))
   (case cc24 then
      (progn (assert (chief-complaint "冲动性或冲动控制问题"))
             (focus IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS)))
   (case cc25 then
      (progn (assert (chief-complaint "自伤或自残"))
             (focus SELF-INJURY-SELF-MUTILATION)))
   (case cc26 then
      (progn (assert (chief-complaint "过度物质使用"))
             (focus EXCESSIVE-SUBTANCE-USE)))
   (case cc27 then
      (progn (assert (chief-complaint "记忆丧失"))
             (focus MEMORY-LOSS)))
   (case cc28 then
      (progn (assert (chief-complaint "认知损害"))
             (focus COGNITIVE-IMPAIRMENT)))
   (case cc29 then
      (progn (assert (chief-complaint "躯体疾病作为病因"))
             (focus MEDICAL-CONDITIONS)))
   (default FALSE)))

(deffunction MAIN::list-chief-complaints ()
   (println "主诉症状：" crlf)
   (println "编号cc1，" "不良学校表现")
   (println "编号cc2，" "儿童或青少年中的行为问题")
   (println "编号cc3，" "言语紊乱")
   (println "编号cc4，" "随境转移")
   (println "编号cc5，" "妄想")
   (println "编号cc6，" "幻觉")
   (println "编号cc7，" "紧张症症状")
   (println "编号cc8，" "高涨或膨胀的心境")
   (println "编号cc9，" "易激惹心境")
   (println "编号cc10，" "抑郁心境")
   (println "编号cc11，" "自杀观念或行为")
   (println "编号cc12，" "精神运动性迟滞")
   (println "编号cc13，" "焦虑")
   (println "编号cc14，" "惊恐发作")
   (println "编号cc15，" "回避行为")
   (println "编号cc16，" "病因涉及创伤或心理社会应激源")
   (println "编号cc17，" "躯体主诉或疾病/外貌焦虑")
   (println "编号cc18，" "食欲改变或异常的进食行为")
   (println "编号cc19，" "失眠")
   (println "编号cc20，" "嗜睡")
   (println "编号cc21，" "女性性功能失调")
   (println "编号cc22，" "男性性功能失调")
   (println "编号cc23，" "攻击行为")
   (println "编号cc24，" "冲动性或冲动控制问题")
   (println "编号cc25，" "自伤或自残")
   (println "编号cc26，" "过度物质使用")
   (println "编号cc27，" "记忆丧失")
   (println "编号cc28，" "认知损害")
   (println "编号cc29，" "躯体疾病作为病因")
   (println)
   (println "请选择编号：")
   )

(deffunction MAIN::ask-question (?question $?allowed-values)
   (print ?question)
   (bind ?answer (read))
   (if (lexemep ?answer) 
       then (bind ?answer (lowcase ?answer)))
   (while (not (member$ ?answer ?allowed-values)) do
      (print ?question)
      (bind ?answer (read))
      (if (lexemep ?answer) 
          then (bind ?answer (lowcase ?answer))))
   ?answer)

(deffunction MAIN::yes-or-no-p (?question)
   (bind ?response (ask-question ?question yes no y n))
   (if (or (eq ?response yes) (eq ?response y))
       then yes 
       else no))

(deffunction MAIN::extract-ordered-facts ()
  (bind ?facts (get-fact-list *))
  (foreach ?fact ?facts
      (bind ?name (fact-relation ?fact))
      (bind ?value (fact-slot-value ?fact implied))
      (if (eq ?name chief-complaint) then
      (printout t "主诉症状：" (nth$ 1 ?value) crlf))
      (if (eq ?name diagnosis) then
      (printout t "鉴别诊断：" (nth$ 1 ?value) crlf))
    )
)

;;;**************************************
;;;* cc1: POOR-SCHOOL-PERFORMANCE RULES *
;;;**************************************
(defrule POOR-SCHOOL-PERFORMANCE::subsystem-banner ""
  (chief-complaint "不良学校表现")
  =>
  (println "用于不良学校表现的决策树" crlf)
  (assert (check intellectual-disability)))

(defrule POOR-SCHOOL-PERFORMANCE::check-intellectual-disability ""
  ?f <- (check intellectual-disability)
  =>
  (retract ?f)
  (bind ?question "与智力功能缺陷（通过临床评估和智力测验确认）和适应功能的缺陷有关，起病于发育期。(yes/no)?")
  (assert (check-intellectual-disability (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::intellectual-disability ""
  ?f <- (check-intellectual-disability yes)
  =>
  (retract ?f)  
  (assert (diagnosis "智力障碍（智力发育障碍）"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::non-intellectual-disability ""
  ?f <- (check-intellectual-disability no)
  =>
  (retract ?f)
  (assert (check social-pragmatic-communication)))

(defrule POOR-SCHOOL-PERFORMANCE::check-social-pragmatic-communication ""
  ?f <- (check social-pragmatic-communication)
  =>
  (retract ?f)
  (bind ?question "发生与言语和非言语交流的社交使用缺陷有关。(yes/no)?")
  (assert (check-social-pragmatic-communication (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::check-autism-spectrum-disorder ""
  ?f <- (check-social-pragmatic-communication yes)
  =>
  (retract ?f)
  (bind ?question "伴有发展和理解人际关系的缺陷，社交情感互动中的缺陷，以及受限、重复的行为、兴趣或活动模式。(yes/no)?")
  (assert (check-autism-spectrum-disorder (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::autism-spectrum-disorder ""
  ?f <- (check-autism-spectrum-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "自闭症谱系障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::social-pragmatic-communication-disorder ""
  ?f <- (check-autism-spectrum-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "社交（语用）交流障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-specific-learning-disorder ""
  ?f <- (check-social-pragmatic-communication no)
  =>
  (retract ?f)
  (bind ?question "发生在有学习和使用学术技能困难的背景下。(yes/no)?")
  (assert (check-specific-learning-disorder (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::specific-learning-disorder ""
  ?f <- (check-specific-learning-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "特定学习障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-language-disorder ""
  ?f <- (check-specific-learning-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生在有持续的语言习得和使用困难的背景下。(yes/no)?")
  (assert (check-language-disorder (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::language-disorder ""
  ?f <- (check-language-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "语言障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-selective-mutism ""
  ?f <- (check-language-disorder no)
  =>
  (retract ?f)
  (bind ?question "与在学校不能说话相关（尽管在家能够说话）。(yes/no)?")
  (assert (check-selective-mutism (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::selective-mutism ""
  ?f <- (check-selective-mutism yes)
  =>
  (retract ?f)  
  (assert (diagnosis "选择性缄默症"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-ADHD ""
  ?f <- (check-selective-mutism no)
  =>
  (retract ?f)
  (bind ?question "与注意力不集中和多动症状有关，起病于12岁之前并有干扰功能的明确证据。(yes/no)?")
  (assert (check-ADHD (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::ADHD ""
  ?f <- (check-ADHD yes)
  =>
  (retract ?f)  
  (assert (diagnosis "注意缺陷/多动障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-disruptive-mood-dysregulation-disorder ""
  ?f <- (check-ADHD no)
  =>
  (retract ?f)
  (bind ?question "与严重的脾气爆发模式有关，完全与所处情境不成比例，伴有爆发间期的持续性愤怒和易激惹。(yes/no)?")
  (assert (check-disruptive-mood-dysregulation-disorder (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::disruptive-mood-dysregulation-disorder ""
  ?f <- (check-disruptive-mood-dysregulation-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "破坏性心境失调障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-conduct-disorder ""
  ?f <- (check-disruptive-mood-dysregulation-disorder no)
  =>
  (retract ?f)
  (bind ?question "与反社会行为模式有关。(yes/no)?")
  (assert (check-conduct-disorder (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::conduct-disorder ""
  ?f <- (check-conduct-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "品行障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-oppositional-defiant-disorder ""
  ?f <- (check-conduct-disorder no)
  =>
  (retract ?f)
  (bind ?question "与对抗、敌意和违拗的行为模式有关。(yes/no)?")
  (assert (check-oppositional-defiant-disorder (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::oppositional-defiant-disorder ""
  ?f <- (check-oppositional-defiant-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "对立违抗障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-substance-use-disorder ""
  ?f <- (check-oppositional-defiant-disorder no)
  =>
  (retract ?f)
  (bind ?question "与过度的物质使用有关。(yes/no)?")
  (assert (check-substance-use-disorder (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::substance-use-disorder ""
  ?f <- (check-substance-use-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质使用障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-separation-anxiety-disorder ""
  ?f <- (check-substance-use-disorder no)
  =>
  (retract ?f)
  (bind ?question "拒绝上学，与害怕分离相关。(yes/no)?")
  (assert (check-separation-anxiety-disorder (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::separation-anxiety-disorder ""
  ?f <- (check-separation-anxiety-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "分离焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-specific-disorder ""
  ?f <- (check-separation-anxiety-disorder no)
  =>
  (retract ?f)
  (bind ?question "干扰学校表现的其他焦虑、心境、精神病性或其他障碍。(yes/no)?")
  (assert (check-specific-disorder (yes-or-no-p ?question))))


(defrule POOR-SCHOOL-PERFORMANCE::specific-disorder ""
  ?f <- (check-specific-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "表明特定的障碍（如精神分裂症，重性抑郁障碍）"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::check-adjustment-disorder ""
  ?f <- (check-specific-disorder no)
  =>
  (retract ?f)
  (bind ?question "对心理社会应激源适应不良的反应。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule POOR-SCHOOL-PERFORMANCE::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule POOR-SCHOOL-PERFORMANCE::final ""
  ?f <- (check-adjustment-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "与精神障碍无关（如不良的工作习惯、破坏性环境）。"))
  (extract-ordered-facts)
  (halt))


;;;**********************************
;;;* cc2: BEHAVIORAL-PROBLEMS RULES *
;;;**********************************
(defrule BEHAVIORAL-PROBLEMS::subsystem-banner ""
  (chief-complaint "儿童或青少年中的行为问题")
  =>
  (println "用于儿童或青少年中的行为问题的决策树" crlf)
  (assert (check substance-use)))

(defrule BEHAVIORAL-PROBLEMS::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "与物质使用（包括药物）有关。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::check-substance-effect ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（或药物）对中枢神经系统的直接生理效应所致。(yes/no)?")
  (assert (check-substance-effect (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::substance-effect ""
  ?f <- (check-substance-effect yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的障碍，物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-substance-use-mode ""
  ?f <- (check-substance-effect no)
  =>
  (retract ?f)
  (bind ?question "与有问题的物质使用模式有关（如为获得毒品的非法行为）。(yes/no)?")
  (assert (check-substance-use-mode (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::substance-use-disorder ""
  ?f <- (check-substance-use-mode yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质使用障碍"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-medical-conditions ""
  (or (check-substance-use-mode no)
      (check-substance-use no)) 
  =>
  (bind ?question "由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::check-delirium ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-delirium (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::delirium ""
  ?f <- (check-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-neurocognitive-disorder ""
  ?f <- (check-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::neurocognitive-disorder ""
  ?f <- (check-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-personality-problem ""
  ?f <- (check-neurocognitive-disorder no)
  =>
  (retract ?f)
  (bind ?question "代表了与先前人格模式相比发生的改变。(yes/no)?")
  (assert (check-personality-problem (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::personality-problem ""
  ?f <- (check-personality-problem yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的人格改变。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::medical-conditions-induced-specific-disorder ""
  ?f <- (check-personality-problem no)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的其他特定的精神障碍或者未特定的精神障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-disruptive-mood-dysregulation-disorder ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "发生在严重的脾气爆发的背景下，完全与所处情境不成比例，伴有爆发间期的持续性愤怒和易激惹。(yes/no)?")
  (assert (check-disruptive-mood-dysregulation-disorder (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::disruptive-mood-dysregulation-disorder ""
  ?f <- (check-disruptive-mood-dysregulation-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "破坏性心境失调障碍"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-hyperactivity-impulsivity-attention ""
  ?f <- (check-disruptive-mood-dysregulation-disorder no)
  =>
  (retract ?f)
  (bind ?question "持续多动、冲动和注意力不集中的症状模式的一部分。(yes/no)?")
  (assert (check-hyperactivity-impulsivity-attention (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::check-ADHD-impairment ""
  ?f <- (check-hyperactivity-impulsivity-attention yes)
  =>
  (retract ?f)
  (bind ?question "发生至少两种不同的场合并引起有临床意义的损害，在12岁之前就有若干症状。(yes/no)?")
  (assert (check-ADHD-impairment (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::ADHD ""
  ?f <- (check-ADHD-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "注意缺陷/多动障碍"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-oppositional-defiant ""
  (or (check-hyperactivity-impulsivity-attention no)
      (check-ADHD-impairment no))
  =>
  (bind ?question "发生与一种争辩、对抗和报复的模式有关。(yes/no)?")
  (assert (check-oppositional-defiant (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::check-oppositional-defiant-impairment ""
  ?f <- (check-oppositional-defiant yes)
  =>
  (retract ?f)
  (bind ?question "鉴于儿童的发育年龄，行为的持续性和频率超出正常界限。(yes/no)?")
  (assert (check-oppositional-defiant-impairment (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::oppositional-defiant-disorder ""
  ?f <- (check-oppositional-defiant-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "对立违抗障碍"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-intellectual-disability ""
  (or (check-oppositional-defiant-impairment no)
      (check-oppositional-defiant no))
  =>
  (bind ?question "发生与智力功能缺陷和伴随的适应功能缺陷有关，起病于发育期。(yes/no)?")
  (assert (check-intellectual-disability (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::intellectual-disability-disorder ""
  ?f <- (check-intellectual-disability yes)
  =>
  (retract ?f)  
  (assert (diagnosis "智力障碍（智力发育障碍）"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-stereotypical-movement ""
  ?f <- (check-intellectual-disability no)
  =>
  (retract ?f)
  (bind ?question "作为刻板运动的后果出现。(yes/no)?")
  (assert (check-stereotypical-movement (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::check-stereotypical-movement-impairment ""
  ?f <- (check-stereotypical-movement yes)
  =>
  (retract ?f)
  (bind ?question "发生与持续的社交交流和社交互动缺陷有关，伴有受限、重复的行为、兴趣或活动模式。(yes/no)?")
  (assert (check-stereotypical-movement-impairment (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::autism-spectrum-disorder ""
  ?f <- (check-stereotypical-movement-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "自闭症谱系障碍"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::stereotypical-movement-disorder ""
  ?f <- (check-stereotypical-movement-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "刻板运动障碍"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-conduct-disorder ""
  ?f <- (check-stereotypical-movement no)
  =>
  (retract ?f)
  (bind ?question "作为反社会模式的一部分。(yes/no)?")
  (assert (check-conduct-disorder (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::conduct-disorder ""
  ?f <- (check-conduct-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "品行障碍"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-pyromania ""
  ?f <- (check-conduct-disorder no)
  =>
  (retract ?f)
  (bind ?question "特征是故意、有目的的放火，与行动前的唤起有关。(yes/no)?")
  (assert (check-pyromania (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::pyromania ""
  ?f <- (check-pyromania yes)
  =>
  (retract ?f)  
  (assert (diagnosis "纵火狂"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-kleptomania ""
  ?f <- (check-pyromania no)
  =>
  (retract ?f)
  (bind ?question "特征是反复地无法抵制偷窃物品的冲动，所偷物品并非需要或为其金钱价值。(yes/no)?")
  (assert (check-kleptomania (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::kleptomania ""
  ?f <- (check-kleptomania yes)
  =>
  (retract ?f)  
  (assert (diagnosis "偷窃狂"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-mood-disorder ""
  ?f <- (check-kleptomania no)
  =>
  (retract ?f)
  (bind ?question "与周期性高涨、欣快或易激惹的心境有关，伴精力增加。(yes/no)?")
  (assert (check-mood-disorder (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::mood-disorder ""
  ?f <- (check-mood-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍和双相II型障碍中的躁狂发作或轻躁狂发作，分裂情感性障碍或环性心境障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-depressive-disorder ""
  ?f <- (check-mood-disorder no)
  =>
  (retract ?f)
  (bind ?question "与抑郁或易激惹的心境发作有关，伴有其他特征性的抑郁症状（如无价值感）。(yes/no)?")
  (assert (check-depressive-disorder (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::depressive-disorder ""
  ?f <- (check-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "在重性抑郁障碍或分裂情感性障碍中的重性抑郁发作；持续性抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-psychotic-disorder ""
  ?f <- (check-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "与精神病性症状有关。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::psychotic-disorder ""
  ?f <- (check-psychotic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神病性障碍（如精神分裂症）。参见用于鉴别诊断的妄想或幻觉的决策树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-stressors ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "对心理社会应激源的症状性反应。(yes/no)?")
  (assert (check-stressors (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::check-stressors-impairment ""
  ?f <- (check-stressors yes)
  =>
  (retract ?f)
  (bind ?question "应激源具有极端的创伤性（如威胁生命的情境）并存在对应激源的反复再体验。(yes/no)?")
  (assert (check-stressors-impairment (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::stress-disorder ""
  ?f <- (check-stressors-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "创伤性应激障碍或急性应激障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::adjustment-disorder ""
  ?f <- (check-stressors-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-dysfunction ""
  ?f <- (check-stressors no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的行为问题代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::specific-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的破坏性、冲动控制及品行障碍，未特定的破坏性、冲动控制及品行障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::check-illegal-behavior ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)
  (bind ?question "为了获益或复仇的非法行为。(yes/no)?")
  (assert (check-illegal-behavior (yes-or-no-p ?question))))

(defrule BEHAVIORAL-PROBLEMS::illegal-behavior ""
  ?f <- (check-illegal-behavior yes)
  =>
  (retract ?f)  
  (assert (diagnosis "儿童或青少年的反社会行为"))
  (extract-ordered-facts)
  (halt))

(defrule BEHAVIORAL-PROBLEMS::final ""
  ?f <- (check-illegal-behavior no)
  =>
  (retract ?f)  
  (assert (diagnosis "与年龄相符的喧闹行为。"))
  (extract-ordered-facts)
  (halt))


;;;*********************************
;;;* cc3: SPEECH-DISTURBANCE RULES *
;;;*********************************
(defrule SPEECH-DISTURBANCE::subsystem-banner ""
  (chief-complaint "言语紊乱")
  =>
  (println "用于言语紊乱的决策树" crlf)
  (assert (check substance-use)))

(defrule SPEECH-DISTURBANCE::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::check-delirium ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-delirium (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::delirium ""
  ?f <- (check-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-neurocognitive-disorder ""
  ?f <- (check-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::neurocognitive-disorder ""
  ?f <- (check-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::substance-use-disorder ""
  ?f <- (check-neurocognitive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::check-medical-conditions-delirium ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-medical-conditions-delirium (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::medical-conditions-delirium ""
  ?f <- (check-medical-conditions-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-medical-conditions-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::aphasia ""
  ?f <- (check-medical-conditions-neurocognitive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "失语（不是一种精神障碍）。"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-bipolar-disorder ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "快速迫促的言语伴有主观的思维奔逸感，与欣快、膨胀或易激惹的心境和精力增加有关。(yes/no)?")
  (assert (check-bipolar-disorder (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::bipolar-I-disorder ""
  ?f <- (check-bipolar-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "在双相I型障碍中的躁狂发作或分裂情感性障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-depressive-disorder ""
  ?f <- (check-bipolar-disorder no)
  =>
  (retract ?f)
  (bind ?question "言语迟缓发生在有抑郁心境发作、兴趣或愉悦感减退和抑郁的其他特征性症状的背景下。(yes/no)?")
  (assert (check-depressive-disorder (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::depressive-disorder ""
  ?f <- (check-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍、双相I型障碍或双相II型障碍或分裂情感性障碍中的重性抑郁发作。"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-catatonia ""
  ?f <- (check-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "模仿他人的言语（模仿言语）。(yes/no)?")
  (assert (check-catatonia (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::catatonia ""
  ?f <- (check-catatonia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "紧张症症状（参见用于鉴别诊断紧张症症状树形图）"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-psychotic-disorder ""
  ?f <- (check-catatonia no)
  =>
  (retract ?f)
  (bind ?question "无条理的言语与妄想、幻觉、明显瓦解的或紧张症行为或阴性症状（如情感表达减少或意志减退）有关。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::check-long-course ""
  ?f <- (check-psychotic-disorder yes)
  =>
  (retract ?f)
  (bind ?question "病程至少6个月。(yes/no)?")
  (assert (check-long-course (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::schizophrenia ""
  ?f <- (check-long-course yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-short-course ""
  ?f <- (check-long-course no)
  =>
  (retract ?f)
  (bind ?question "病程1个月至6个月。(yes/no)?")
  (assert (check-short-course (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::schizophreniform ""
  ?f <- (check-short-course yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症样障碍"))
  (extract-ordered-facts)
  (halt))


(defrule SPEECH-DISTURBANCE::transient-psychotic-disorder ""
  ?f <- (check-short-course no)
  =>
  (retract ?f)  
  (assert (diagnosis "短暂精神病性障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-language-disorder ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "言语困难与由于理解和生成方面的缺陷所致的语言习得和使用上的问题有关。(yes/no)?")
  (assert (check-language-disorder (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::language-disorder ""
  ?f <- (check-language-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "语言障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-speech-sound-disorder ""
  ?f <- (check-language-disorder no)
  =>
  (retract ?f)
  (bind ?question "妨碍可理解性的语音生成困难。(yes/no)?")
  (assert (check-speech-sound-disorder (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::speech-sound-disorder ""
  ?f <- (check-speech-sound-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "语音障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-stuttering ""
  ?f <- (check-speech-sound-disorder no)
  =>
  (retract ?f)
  (bind ?question "言语的正常流畅性和时间模式上的紊乱，相对年龄和语言技巧而言是不恰当的。(yes/no)?")
  (assert (check-stuttering (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::stutteringr ""
  ?f <- (check-stuttering yes)
  =>
  (retract ?f)  
  (assert (diagnosis "童年起病的流畅性障碍（口吃）"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-social-communication ""
  ?f <- (check-stuttering no)
  =>
  (retract ?f)
  (bind ?question "言语和非言语交流的社交使用上的缺陷。(yes/no)?")
  (assert (check-social-communication (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::check-autism-spectrum-disorder ""
  ?f <- (check-social-communication yes)
  =>
  (retract ?f)
  (bind ?question "伴有发展和理解人际关系上的缺陷，社交情感互动中的缺陷，以及受限、重复的行为、兴趣或活动模式。(yes/no)?")
  (assert (check-autism-spectrum-disorder (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::autism-spectrum-disorder ""
  ?f <- (check-autism-spectrum-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "自闭症谱系障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::social-pragmatic-disorder ""
  ?f <- (check-autism-spectrum-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "社交（语用）交流障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-tic-disorder ""
  ?f <- (check-social-communication no)
  =>
  (retract ?f)
  (bind ?question "反复的、节律性的发声。(yes/no)?")
  (assert (check-tic-disorder (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::tic-disorder ""
  ?f <- (check-tic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "抽动障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::check-dysfunction ""
  ?f <- (check-tic-disorder no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的言语紊乱代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule SPEECH-DISTURBANCE::unspecific-communication-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)  
  (assert (diagnosis "未特定的交流障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SPEECH-DISTURBANCE::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "言语上的“正常”变异"))
  (extract-ordered-facts)
  (halt))


;;;******************************
;;;* cc4: DISTRACTIBILITY RULES *
;;;******************************
(defrule DISTRACTIBILITY::subsystem-banner ""
  (chief-complaint "随境转移")
  =>
  (println "用于随境转移的决策树" crlf)
  (assert (check substance-use)))

(defrule DISTRACTIBILITY::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的直接效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::substance-use-disorder ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断。"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于一般躯体疾病的直接效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::check-delirium ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-delirium (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::delirium ""
  ?f <- (check-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::check-neurocognitive-disorder ""
  ?f <- (check-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::neurocognitive-disorder ""
  ?f <- (check-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::other-specific-disorder ""
  ?f <- (check-neurocognitive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的其他特定的或未特定的精神障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::check-bipolar-disorder ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "与无法滤除不重要的外部刺激相关，伴有其他躁狂症状。(yes/no)?")
  (assert (check-bipolar-disorder (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::bipolar-disorder ""
  ?f <- (check-bipolar-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍或分裂情感性障碍中的躁狂发作。"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::check-depressive-disorder ""
  ?f <- (check-bipolar-disorder no)
  =>
  (retract ?f)
  (bind ?question "与无法集中注意力相关，伴有其他抑郁症状。(yes/no)?")
  (assert (check-depressive-disorder (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::depressive-disorder ""
  ?f <- (check-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍，双相I型障碍或双相II型障碍，或分裂情感性障碍中的重性抑郁发作，持续性抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::check-psychotic-disorder ""
  ?f <- (check-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "与妄想或幻觉有关。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::psychotic-disorder ""
  ?f <- (check-psychotic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神病性障碍。参见用于鉴别诊断的妄想树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::check-ADHD ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "伴有其他的注意力不集中和/或多动/冲动症状。(yes/no)?")
  (assert (check-ADHD (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::ADHD ""
  ?f <- (check-ADHD yes)
  =>
  (retract ?f)  
  (assert (diagnosis "注意缺陷/多动障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::check-stressors ""
  ?f <- (check-ADHD no)
  =>
  (retract ?f)
  (bind ?question "集中注意力的问题作为对创伤性应激源的反应出现。(yes/no)?")
  (assert (check-stressors (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::check-course ""
  ?f <- (check-stressors yes)
  =>
  (retract ?f)
  (bind ?question "持续至少1个月。(yes/no)?")
  (assert (check-course (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::PTSD ""
  ?f <- (check-course yes)
  =>
  (retract ?f)  
  (assert (diagnosis "创伤后应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::acute-stress-disorder ""
  ?f <- (check-course no)
  =>
  (retract ?f)  
  (assert (diagnosis "急性应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::check-anxiety ""
  ?f <- (check-stressors no)
  =>
  (retract ?f)
  (bind ?question "与难以集中注意力有关，伴有至少6个月的过度焦虑和担心。(yes/no)?")
  (assert (check-anxiety (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::generalized-anxiety-disorder ""
  ?f <- (check-anxiety yes)
  =>
  (retract ?f)  
  (assert (diagnosis "广泛性焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::check-dysfunction ""
  ?f <- (check-anxiety no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的随境转移代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::check-adjustment-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源的反应出现。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule DISTRACTIBILITY::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::specific-disorder ""
  ?f <- (check-adjustment-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的注意缺陷/多动障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DISTRACTIBILITY::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”随境转移"))
  (extract-ordered-facts)
  (halt))


;;;************************
;;;* cc5: DELUSIONS RULES *
;;;************************
(defrule DELUSIONS::subsystem-banner ""
  (chief-complaint "妄想")
  =>
  (println "用于妄想的决策树" crlf)
  (assert (check belief-system)))

(defrule DELUSIONS::check-belief-system ""
  ?f <- (check belief-system)
  =>
  (retract ?f)
  (bind ?question "一种文化或宗教上认可的信念系统的表现。(yes/no)?")
  (assert (check-belief-system (yes-or-no-p ?question))))

(defrule DELUSIONS::belief-system ""
  ?f <- (check-belief-system yes)
  =>
  (retract ?f)  
  (assert (diagnosis "非病理性的严格遵守的信念，无精神障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-substance-use ""
  ?f <- (check-belief-system no)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule DELUSIONS::check-delirium ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-delirium (yes-or-no-p ?question))))

(defrule DELUSIONS::delirium ""
  ?f <- (check-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-delusion-impairment ""
  ?f <- (check-delirium no)
  =>
  (retract ?f)
  (bind ?question "妄想为主要临床表现且严重到需要临床关注。(yes/no)?")
  (assert (check-delusion-impairment (yes-or-no-p ?question))))

(defrule DELUSIONS::substance-addictive-disorder ""
  ?f <- (check-delusion-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的精神障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::substance-intoxication-withdrawal ""
  ?f <- (check-delusion-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule DELUSIONS::check-medical-conditions-delirium ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-medical-conditions-delirium (yes-or-no-p ?question))))

(defrule DELUSIONS::medical-conditions-delirium ""
  ?f <- (check-medical-conditions-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule DELUSIONS::neurocognitive-disorder ""
  ?f <- (check-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::psychotic-disorder ""
  ?f <- (check-neurocognitive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的精神病性障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-bipolar-disorder ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "仅发生在高涨、膨胀或易激惹的心境发作的背景下，伴有精力增加。(yes/no)?")
  (assert (check-bipolar-disorder (yes-or-no-p ?question))))

(defrule DELUSIONS::bipolar-disorder ""
  ?f <- (check-bipolar-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍中的躁狂发作伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-depressive-disorder ""
  ?f <- (check-bipolar-disorder no)
  =>
  (retract ?f)
  (bind ?question "仅发生在发作抑郁心境或是兴趣或愉悦感减退的背景下，伴有特征性的抑郁症状。(yes/no)?")
  (assert (check-depressive-disorder (yes-or-no-p ?question))))

(defrule DELUSIONS::depressive-disorder ""
  ?f <- (check-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍或双相I型障碍或双相II型障碍中的重性抑郁发作伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-delusion-duration ""
  ?f <- (check-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "妄想持续1个月或更久。(yes/no)?")
  (assert (check-delusion-duration (yes-or-no-p ?question))))

;;;check-delusion-duration no
(defrule DELUSIONS::check-delusion-short-duration ""
  ?f <- (check-delusion-duration no)
  =>
  (retract ?f)
  (bind ?question "妄想的病程超过1天但少于1个月。(yes/no)?")
  (assert (check-delusion-short-duration (yes-or-no-p ?question))))

(defrule DELUSIONS::transient-psychotic-disorder ""
  ?f <- (check-delusion-short-duration yes)
  =>
  (retract ?f)  
  (assert (diagnosis "短暂精神病性障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-dysfunction ""
  ?f <- (check-delusion-short-duration no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的妄想引起有临床意义的损害或痛苦。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule DELUSIONS::specific-unspecific-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的精神分裂症谱系及其他精神病性障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "非病理性的妄想。"))
  (extract-ordered-facts)
  (halt))

;;;check-delusion-duration yes
(defrule DELUSIONS::check-hallucinations-catatonia-negative-symptoms ""
  ?f <- (check-delusion-duration yes)
  =>
  (retract ?f)
  (bind ?question "伴有幻觉、言语瓦解、明显瓦解的或紧张症行为，或阴性症状。(yes/no)?")
  (assert (check-hallucinations-catatonia-negative-symptoms (yes-or-no-p ?question))))

;;;check-hallucinations-catatonia-negative-symptoms no
(defrule DELUSIONS::check-depressive-mania-history ""
  ?f <- (check-hallucinations-catatonia-negative-symptoms no)
  =>
  (retract ?f)
  (bind ?question "重性抑郁或躁狂发作的历史。(yes/no)?")
  (assert (check-depressive-mania-history (yes-or-no-p ?question))))

(defrule DELUSIONS::check-overall-course-of-mood-seizure ""
  ?f <- (check-depressive-mania-history yes)
  =>
  (retract ?f)
  (bind ?question "相对于妄想周期的病程而言，心境发作的总病程是短暂的。(yes/no)?")
  (assert (check-overall-course-of-mood-seizure (yes-or-no-p ?question))))

(defrule DELUSIONS::check-dysfunction-2 ""
  (or (check-depressive-mania-history no)
      (check-overall-course-of-mood-seizure yes))
  =>
  (bind ?question "除妄想外，功能未显著受损。(yes/no)?")
  (assert (check-dysfunction-2 (yes-or-no-p ?question))))

(defrule DELUSIONS::delusional-disorder ""
  ?f <- (check-dysfunction-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "妄想障碍（如果有重性抑郁障碍或躁狂发作史，则加上共病的双相I型障碍和双相II型障碍，或重性抑郁障碍）。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::specific-unspecific-schizophrenia-psychotic-disorder ""
  ?f <- (check-dysfunction-2 no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的精神分裂症谱系及其他精神病性障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-delusion-in-mood-seizure ""
  ?f <- (check-overall-course-of-mood-seizure no)
  =>
  (retract ?f)
  (bind ?question "妄想仅出现在心境发作期间。(yes/no)?")
  (assert (check-delusion-in-mood-seizure (yes-or-no-p ?question))))

(defrule DELUSIONS::bipolar-I-II-disorder ""
  ?f <- (check-delusion-in-mood-seizure yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍、双相II型障碍或重性抑郁障碍，伴精神病性症状。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::specific-unspecific-schizophrenia-psychotic-disorder-2 ""
  ?f <- (check-delusion-in-mood-seizure no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的精神分裂症谱系及其他精神病性障碍。"))
  (extract-ordered-facts)
  (halt))

;;;check-hallucinations-catatonia-negative-symptoms yes
(defrule DELUSIONS::check-depressive-mania-history-2 ""
  ?f <- (check-hallucinations-catatonia-negative-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "重性抑郁或躁狂发作的历史。(yes/no)?")
  (assert (check-depressive-mania-history-2 (yes-or-no-p ?question))))

(defrule DELUSIONS::check-psychotic-mood-seizure-course ""
  ?f <- (check-depressive-mania-history-2 yes)
  =>
  (retract ?f)
  (bind ?question "在一个连续的疾病周期中，精神病性症状与心境发作并存。(yes/no)?")
  (assert (check-psychotic-mood-seizure-course (yes-or-no-p ?question))))

(defrule DELUSIONS::check-minor-mood-seizure-course ""
  ?f <- (check-psychotic-mood-seizure-course yes)
  =>
  (retract ?f)
  (bind ?question "在一个连续的疾病周期中，心境发作在疾病活跃期和残留期的总病程中占据少数时间。(yes/no)?")
  (assert (check-minor-mood-seizure-course (yes-or-no-p ?question))))

(defrule DELUSIONS::check-minor-course ""
  (or (check-depressive-mania-history-2 no)
      (check-psychotic-mood-seizure-course no)
      (check-minor-mood-seizure-course yes))
  =>
  (bind ?question "病程至少6个月。(yes/no)?")
  (assert (check-minor-course (yes-or-no-p ?question))))

(defrule DELUSIONS::schizophrenia ""
  ?f <- (check-minor-course yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症（如果有重性抑郁障碍或躁狂发作史，则加上共病的双相I型障碍和双相II型障碍，或重性抑郁障碍）。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::schizophreniform ""
  ?f <- (check-minor-course no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症样障碍（如果有重性抑郁障碍或躁狂发作史，则加上共病的双相I型障碍和双相II型障碍，或重性抑郁障碍）。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-schizoaffective-disorder ""
  ?f <- (check-minor-mood-seizure-course no)
  =>
  (retract ?f)
  (bind ?question "在终生的病程中，在没有重性抑郁发作或躁狂发作的情况下，妄想或幻觉持续至少2周。(yes/no)?")
  (assert (check-schizoaffective-disorder (yes-or-no-p ?question))))

(defrule DELUSIONS::schizoaffective-disorder ""
  ?f <- (check-schizoaffective-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "分裂情感性障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::check-bipolar-disorder-2 ""
  ?f <- (check-schizoaffective-disorder no)
  =>
  (retract ?f)
  (bind ?question "精神病性症状仅在心境发作时出现。(yes/no)?")
  (assert (check-bipolar-disorder-2 (yes-or-no-p ?question))))

(defrule DELUSIONS::bipolar-disorder-2 ""
  ?f <- (check-bipolar-disorder-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍、双相II型障碍或重性抑郁障碍，伴精神病性症状。"))
  (extract-ordered-facts)
  (halt))

(defrule DELUSIONS::other-disorders ""
  ?f <- (check-bipolar-disorder-2 no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的精神分裂症谱系及其他精神病性障碍。"))
  (extract-ordered-facts)
  (halt))


;;;*****************************
;;;* cc6: HALLUCINATIONS RULES *
;;;*****************************
(defrule HALLUCINATIONS::subsystem-banner ""
  (chief-complaint "幻觉")
  =>
  (println "用于幻觉的决策树" crlf)
  (assert (check substance-use)))

(defrule HALLUCINATIONS::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::check-substance-use-delirium ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-substance-use-delirium (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::substance-use-delirium ""
  ?f <- (check-substance-use-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-hallucinations-impairment ""
  ?f <- (check-substance-use-delirium no)
  =>
  (retract ?f)
  (bind ?question "幻觉为主要临床表现且严重到需要临床关注。(yes/no)?")
  (assert (check-hallucinations-impairment (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::substance-use-psychotic-disorder ""
  ?f <- (check-hallucinations-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的精神病性障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::substance-use-intoxication-withdrawal ""
  ?f <- (check-hallucinations-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::check-medical-conditions-delirium ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-medical-conditions-delirium (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::medical-conditions-delirium ""
  ?f <- (check-medical-conditions-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-medical-conditions-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::medical-conditions-psychotic-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的精神病性障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-convertion-disorder ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "有完整自知力的幻觉体验，不伴有其他精神病性症状，通常以多种感觉形式出现，并具有奇异的或幼稚的内容（“假性幻觉”）。(yes/no)?")
  (assert (check-convertion-disorder (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::convertion-disorder ""
  ?f <- (check-convertion-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "转换障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-belief-system ""
  ?f <- (check-convertion-disorder no)
  =>
  (retract ?f)
  (bind ?question "幻觉体验是文化上认可的。(yes/no)?")
  (assert (check-belief-system (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::belief-system ""
  ?f <- (check-belief-system yes)
  =>
  (retract ?f)  
  (assert (diagnosis "无精神障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-bipolar-I-disorder ""
  ?f <- (check-belief-system no)
  =>
  (retract ?f)
  (bind ?question "仅发生在高涨、膨胀或易激惹的心境发作的背景下，伴有精力增加。(yes/no)?")
  (assert (check-bipolar-I-disorder (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::bipolar-I-disorder ""
  ?f <- (check-bipolar-I-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍中的躁狂发作伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-depressive-disorder ""
  ?f <- (check-bipolar-I-disorder no)
  =>
  (retract ?f)
  (bind ?question "仅发生在发作抑郁心境或是兴趣或愉悦感减退的背景下，伴有特征性的抑郁症状。(yes/no)?")
  (assert (check-depressive-disorder (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::depressive-disorder ""
  ?f <- (check-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍或双相I型障碍或双相II型障碍中的重性抑郁发作伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-hallucinations-duration ""
  ?f <- (check-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "幻觉持续1个月或更久。(yes/no)?")
  (assert (check-hallucinations-duration (yes-or-no-p ?question))))

;;;check-hallucinations-duration no
(defrule HALLUCINATIONS::check-hallucinations-short-duration ""
  ?f <- (check-hallucinations-duration no)
  =>
  (retract ?f)
  (bind ?question "幻觉的病程超过1天但少于1个月。(yes/no)?")
  (assert (check-hallucinations-short-duration (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::transient-psychotic-disorder ""
  ?f <- (check-hallucinations-short-duration yes)
  =>
  (retract ?f)  
  (assert (diagnosis "短暂精神病性障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-dysfunction ""
  ?f <- (check-hallucinations-short-duration no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的幻觉引起有临床意义的损害或痛苦。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::specific-schizophrenia-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的精神分裂症谱系及其他精神病性障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "非病理性幻觉。"))
  (extract-ordered-facts)
  (halt))

;;;check-hallucinations-duration yes
(defrule HALLUCINATIONS::check-delusion-catatonia-negative-symptoms ""
  ?f <- (check-hallucinations-duration yes)
  =>
  (retract ?f)
  (bind ?question "伴有妄想、言语瓦解、明显瓦解的或紧张症行为，或阴性症状。(yes/no)?")
  (assert (check-delusion-catatonia-negative-symptoms (yes-or-no-p ?question))))

;;;check-delusion-catatonia-negative-symptoms yes
(defrule HALLUCINATIONS::check-depressive-mania-history ""
  ?f <- (check-delusion-catatonia-negative-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "重性抑郁或躁狂发作的历史。(yes/no)?")
  (assert (check-depressive-mania-history (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::check-psychotic-mood-seizure ""
  ?f <- (check-depressive-mania-history yes)
  =>
  (retract ?f)
  (bind ?question "在一个连续的疾病周期中，精神病性症状与心境发作并存。(yes/no)?")
  (assert (check-psychotic-mood-seizure (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::check-overall-course-of-mood-seizure ""
  ?f <- (check-psychotic-mood-seizure yes)
  =>
  (retract ?f)
  (bind ?question "在一个连续的疾病周期中，心境发作在疾病活跃期和残留期的总病程中占据少数时间。(yes/no)?")
  (assert (check-overall-course-of-mood-seizure (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::check-minor-course ""
  (or (check-depressive-mania-history no)
      (check-psychotic-mood-seizure no)
      (check-overall-course-of-mood-seizure yes))
  =>
  (bind ?question "病程至少6个月。(yes/no)?")
  (assert (check-minor-course (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::schizophrenia ""
  ?f <- (check-minor-course yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症（如果有重性抑郁障碍或躁狂发作史，则加上共病的双相I型障碍和双相II型障碍，或重性抑郁障碍）。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::schizophreniform ""
  ?f <- (check-minor-course no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症样障碍（如果有重性抑郁障碍或躁狂发作史，则加上共病的双相I型障碍和双相II型障碍，或重性抑郁障碍）。"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-schizoaffective-disorder ""
  ?f <- (check-overall-course-of-mood-seizure no)
  =>
  (retract ?f)
  (bind ?question "在终生的病程中，在没有重性抑郁发作或躁狂发作的情况下，妄想或幻觉持续至少2周。(yes/no)?")
  (assert (check-schizoaffective-disorder (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::schizoaffective-disorder ""
  ?f <- (check-schizoaffective-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "分裂情感性障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HALLUCINATIONS::check-psychotic-in-mood-seizure ""
  ?f <- (check-schizoaffective-disorder no)
  =>
  (retract ?f)
  (bind ?question "精神病性症状仅在心境发作时出现。(yes/no)?")
  (assert (check-psychotic-in-mood-seizure (yes-or-no-p ?question))))

(defrule HALLUCINATIONS::bipolar-I-disorder-2 ""
  ?f <- (check-psychotic-in-mood-seizure yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍、双相II型障碍或重性抑郁障碍，伴精神病性症状。"))
  (extract-ordered-facts)
  (halt))

;;;check-delusion-catatonia-negative-symptoms no
;;;check-psychotic-in-mood-seizure no
(defrule HALLUCINATIONS::specific-unspecific-schizophrenia ""
  (or (check-delusion-catatonia-negative-symptoms no)
      (check-psychotic-in-mood-seizure no))
  =>
  (assert (diagnosis "其他特定的或未特定的精神分裂症谱系及其他精神病性障碍。"))
  (extract-ordered-facts)
  (halt))


;;;*********************************
;;;* cc7: CATATONIC-SYMPTOMS RULES *
;;;*********************************
(defrule CATATONIC-SYMPTOMS::subsystem-banner ""
  (chief-complaint "紧张症症状")
  =>
  (println "用于紧张症症状的决策树" crlf)
  (assert (check catatonic-symptoms)))

(defrule CATATONIC-SYMPTOMS::check-catatonic-symptoms ""
  ?f <- (check catatonic-symptoms)
  =>
  (retract ?f)
  (bind ?question "存在紧张症综合征（即临床主要表现为下列紧张症症状中的三项或更多：木僵，僵住，蜡样屈曲，缄默，违拗，作态，装相，刻板运动，激越，扮鬼脸，模仿言语，模仿动作。）(yes/no)?")
  (assert (check-catatonic-symptoms (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::check-substance-intoxication-withdrawal ""
  ?f <- (check-catatonic-symptoms no)
  =>
  (retract ?f)
  (bind ?question "发生在有学习和使用学术技能困难的背景下。(yes/no)?")
  (assert (check-substance-intoxication-withdrawal (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::substance-intoxication-withdrawal ""
  ?f <- (check-substance-intoxication-withdrawal yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::check-neuroleptics ""
  ?f <- (check-substance-intoxication-withdrawal no)
  =>
  (retract ?f)
  (bind ?question "判定由于神经阻滞剂药物使用所致。(yes/no)?")
  (assert (check-neuroleptics (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::unspecific-catatonia ""
  ?f <- (check-neuroleptics no)
  =>
  (retract ?f)  
  (assert (diagnosis "未特定的紧张症。如果仅限于运动活动减少，参见用于鉴别诊断的精神运动性迟滞树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::check-neuroleptic-malignant-syndrome ""
  ?f <- (check-neuroleptics yes)
  =>
  (retract ?f)
  (bind ?question "伴有肌肉僵硬和体温升高。(yes/no)?")
  (assert (check-neuroleptic-malignant-syndrome (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::neuroleptic-malignant-syndrome ""
  ?f <- (check-neuroleptic-malignant-syndrome yes)
  =>
  (retract ?f)  
  (assert (diagnosis "神经阻滞剂恶性综合征"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::check-acute-dystonia ""
  ?f <- (check-neuroleptic-malignant-syndrome no)
  =>
  (retract ?f)
  (bind ?question "异常的姿势或肌肉痉挛。(yes/no)?")
  (assert (check-acute-dystonia (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::acute-dystonia ""
  ?f <- (check-acute-dystonia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "药物所致的急性肌张力障碍"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::check-Parkinson-syndrome ""
  ?f <- (check-acute-dystonia no)
  =>
  (retract ?f)
  (bind ?question "肌肉僵硬，通常伴有震颤和/或运动不能。(yes/no)?")
  (assert (check-Parkinson-syndrome (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::Parkinson-syndrome ""
  ?f <- (check-Parkinson-syndrome yes)
  =>
  (retract ?f)  
  (assert (diagnosis "神经阻滞剂所致的帕金森氏综合征。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::motor-disorder ""
  ?f <- (check-Parkinson-syndrome no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他药物所致的运动障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::check-neuro-medical-conditions ""
  ?f <- (check-catatonic-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "判定由于某种神经系统或其他躯体疾病所致。(yes/no)?")
  (assert (check-neuro-medical-conditions (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::check-medical-conditions-delirium ""
  ?f <- (check-neuro-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-medical-conditions-delirium (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::medical-conditions-delirium ""
  ?f <- (check-medical-conditions-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::medical-conditions-catatonia ""
  ?f <- (check-medical-conditions-delirium no)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的紧张症障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::check-bipolar-disorder ""
  ?f <- (check-neuro-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "仅发生在高涨、膨胀或易激惹的心境发作的背景下，伴有精力增加。(yes/no)?")
  (assert (check-bipolar-disorder (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::bipolar-disorder ""
  ?f <- (check-bipolar-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "与双相I型障碍中的躁狂发作有关的紧张症。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::check-depressive-disorder ""
  ?f <- (check-bipolar-disorder no)
  =>
  (retract ?f)
  (bind ?question "仅发生在发作抑郁心境或是兴趣或愉悦感减退的背景下，伴有特征性的抑郁症状。(yes/no)?")
  (assert (check-depressive-disorder (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::depressive-disorder ""
  ?f <- (check-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "与重性抑郁障碍或双相I型障碍或双相II型障碍中的重性抑郁发作有关的紧张症。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::check-psychotic-disorder ""
  ?f <- (check-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生其他精神病性症状（如妄想，幻觉，言语瓦解）的背景下。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::psychotic-disorder ""
  ?f <- (check-psychotic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "与精神分裂症、分裂情感性障碍、精神分裂症样障碍或短暂性精神病性障碍有关的紧张症。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::check-dysfunction ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的紧张症症状代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule CATATONIC-SYMPTOMS::unspecific-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)  
  (assert (diagnosis "未特定的紧张症。"))
  (extract-ordered-facts)
  (halt))

(defrule CATATONIC-SYMPTOMS::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神运动行为或活动的“正常”改变。"))
  (extract-ordered-facts)
  (halt))


;;;**************************************
;;;* cc8: ELEVATED-EXPANSIVE-MOOD RULES *
;;;**************************************
(defrule ELEVATED-EXPANSIVE-MOOD::subsystem-banner ""
  (chief-complaint "高涨或膨胀的心境")
  =>
  (println "用于高涨或膨胀的心境的决策树" crlf)
  (assert (check substance-use)))

(defrule ELEVATED-EXPANSIVE-MOOD::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::check-elevated-expansive-mood-impairment ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "高涨或膨胀的心境为主要临床表现并严重到需要临床关注。(yes/no)?")
  (assert (check-elevated-expansive-mood-impairment (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::substance-use-bipolar-disorder ""
  ?f <- (check-elevated-expansive-mood-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的双相障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::substance-intoxication-withdrawal ""
  ?f <- (check-elevated-expansive-mood-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::check-medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-medical-conditions-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::medical-conditions-bipolar-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的双相及相关障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::check-mania-symptoms ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "符合躁狂发作的诊断标准（即至少1周的心境高涨或膨胀，伴活动或精力增加，并有至少三个其他特征性症状，严重到引起明显的损害）。(yes/no)?")
  (assert (check-mania-symptoms (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::mania ""
  ?f <- (check-mania-symptoms yes)
  =>
  (retract ?f)
  (println "躁狂发作")
  (assert (check history)))

(defrule ELEVATED-EXPANSIVE-MOOD::check-hypomania-symptoms ""
  ?f <- (check-mania-symptoms no)
  =>
  (retract ?f)
  (bind ?question "符合轻躁狂发作的诊断标准（即至少4天的心境高涨或膨胀，伴活动或精力增加，并有至少三个其他特征性症状，但尚未严重到引起明显的损害）。(yes/no)?")
  (assert (check-hypomania-symptoms (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::hypomania ""
  ?f <- (check-hypomania-symptoms yes)
  =>
  (retract ?f)
  (println "轻躁狂发作")
  (assert (check history)))

(defrule ELEVATED-EXPANSIVE-MOOD::check-mania-history ""
  (or (check history)
      (check-hypomania-symptoms no))
  =>
  (bind ?question "目前或既往有躁狂发作。(yes/no)?")
  (assert (check-mania-history (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::check-delusion-hallucination-history ""
  ?f <- (check-mania-history yes)
  =>
  (retract ?f)
  (bind ?question "妄想或幻觉史。(yes/no)?")
  (assert (check-delusion-hallucination-history (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::bipolar-I-disorder ""
  ?f <- (check-delusion-hallucination-history no)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::check-psychotic-symptoms ""
  ?f <- (check-delusion-hallucination-history yes)
  =>
  (retract ?f)
  (bind ?question "精神病性症状仅出现在躁狂或重性抑郁发作期间。(yes/no)?")
  (assert (check-psychotic-symptoms (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::psychotic-bipolar-I-disorder ""
  ?f <- (check-psychotic-symptoms yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍，伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::schizophrenia-psychotic-disorder ""
  ?f <- (check-psychotic-symptoms no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症谱系或其他精神病性障碍（参见用于鉴别诊断的妄想树形图或幻觉树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::check-hypomania-history ""
  ?f <- (check-mania-history no)
  =>
  (retract ?f)
  (bind ?question "目前或既往有轻躁狂发作并有至少一次重性抑郁发作。(yes/no)?")
  (assert (check-hypomania-history (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::check-delusion-hallucination-history-2 ""
  ?f <- (check-hypomania-history yes)
  =>
  (retract ?f)
  (bind ?question "妄想或幻觉史。(yes/no)?")
  (assert (check-delusion-hallucination-history-2 (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::bipolar-II-disorder ""
  ?f <- (check-delusion-hallucination-history-2 no)
  =>
  (retract ?f)  
  (assert (diagnosis "双相II型障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::check-psychotic-symptoms-2 ""
  ?f <- (check-delusion-hallucination-history-2 yes)
  =>
  (retract ?f)
  (bind ?question "精神病性症状仅出现在躁狂或重性抑郁发作期间。(yes/no)?")
  (assert (check-psychotic-symptoms-2 (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::psychotic-bipolar-II-disorder ""
  ?f <- (check-psychotic-symptoms-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相II型障碍，伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::schizophrenia-psychotic-disorder-2 ""
  ?f <- (check-psychotic-symptoms-2 no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症谱系或其他精神病性障碍（参见用于鉴别诊断的妄想树形图或幻觉树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::check-cyclothymic-disorder ""
  ?f <- (check-hypomania-history no)
  =>
  (retract ?f)
  (bind ?question "2年以上的轻躁狂症状和周期性抑郁心境。(yes/no)?")
  (assert (check-cyclothymic-disorder (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::cyclothymic-disorder ""
  ?f <- (check-cyclothymic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "环性心境障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::check-mood-in-gambling ""
  ?f <- (check-cyclothymic-disorder no)
  =>
  (retract ?f)
  (bind ?question "高涨或欣快的心境仅限于赌博时期。(yes/no)?")
  (assert (check-mood-in-gambling (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::check-gambling-disorder ""
  ?f <- (check-mood-in-gambling yes)
  =>
  (retract ?f)
  (bind ?question "持续并成问题的赌博行为导致有临床意义的损害或痛苦。(yes/no)?")
  (assert (check-gambling-disorder (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::gambling-disorder ""
  ?f <- (check-gambling-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "赌博障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::non-gambling-disorder ""
  ?f <- (check-gambling-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "正常的赌博行为。"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::check-dysfunction ""
  ?f <- (check-mood-in-gambling no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的躁狂或轻躁狂症状代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule ELEVATED-EXPANSIVE-MOOD::specific-unspecific-bipolar-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的双相及相关障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule ELEVATED-EXPANSIVE-MOOD::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”高涨或欣快的心境。"))
  (extract-ordered-facts)
  (halt))


;;;*****************************
;;;* cc9: IRRITABLE-MOOD RULES *
;;;*****************************
(defrule IRRITABLE-MOOD::subsystem-banner ""
  (chief-complaint "易激惹心境")
  =>
  (println "用于易激惹心境的决策树" crlf)
  (assert (check substance-use)))

(defrule IRRITABLE-MOOD::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::check-irritable-mood-impairment ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "易激惹心境为主要临床表现并严重到需要临床关注。(yes/no)?")
  (assert (check-irritable-mood-impairment (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::substance-use-bipolar-disorder ""
  ?f <- (check-irritable-mood-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的双相障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::substance-intoxication-withdrawal ""
  ?f <- (check-irritable-mood-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::check-medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-medical-conditions-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::medical-conditions-bipolar-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的双相及相关障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-mania-symptoms ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "符合躁狂发作的诊断标准（即至少1周的心境高涨或膨胀，伴活动或精力增加，并有至少三个其他特征性症状，严重到引起明显的损害）。(yes/no)?")
  (assert (check-mania-symptoms (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::mania ""
  ?f <- (check-mania-symptoms yes)
  =>
  (retract ?f)
  (println "躁狂发作")
  (assert (check history)))

(defrule IRRITABLE-MOOD::check-hypomania-symptoms ""
  ?f <- (check-mania-symptoms no)
  =>
  (retract ?f)
  (bind ?question "符合轻躁狂发作的诊断标准（即至少4天的心境高涨或膨胀，伴活动或精力增加，并有至少三个其他特征性症状，但尚未严重到引起明显的损害）。(yes/no)?")
  (assert (check-hypomania-symptoms (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::hypomania ""
  ?f <- (check-hypomania-symptoms yes)
  =>
  (retract ?f)
  (println "轻躁狂发作")
  (assert (check history)))

(defrule IRRITABLE-MOOD::check-mania-history ""
  (or (check history)
      (check-hypomania-symptoms no))
  =>
  (bind ?question "目前或既往有躁狂发作。(yes/no)?")
  (assert (check-mania-history (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::check-delusion-hallucination-history ""
  ?f <- (check-mania-history yes)
  =>
  (retract ?f)
  (bind ?question "妄想或幻觉史。(yes/no)?")
  (assert (check-delusion-hallucination-history (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::bipolar-I-disorder ""
  ?f <- (check-delusion-hallucination-history no)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-psychotic-symptoms ""
  ?f <- (check-delusion-hallucination-history yes)
  =>
  (retract ?f)
  (bind ?question "精神病性症状仅出现在躁狂或重性抑郁发作期间。(yes/no)?")
  (assert (check-psychotic-symptoms (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::psychotic-bipolar-I-disorder ""
  ?f <- (check-psychotic-symptoms yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍，伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::schizophrenia-psychotic-disorder ""
  ?f <- (check-psychotic-symptoms no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症谱系或其他精神病性障碍（参见用于鉴别诊断的妄想树形图或幻觉树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-hypomania-history ""
  ?f <- (check-mania-history no)
  =>
  (retract ?f)
  (bind ?question "目前或既往有轻躁狂发作并有至少一次重性抑郁发作。(yes/no)?")
  (assert (check-hypomania-history (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::check-delusion-hallucination-history-2 ""
  ?f <- (check-hypomania-history yes)
  =>
  (retract ?f)
  (bind ?question "妄想或幻觉史。(yes/no)?")
  (assert (check-delusion-hallucination-history-2 (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::bipolar-II-disorder ""
  ?f <- (check-delusion-hallucination-history-2 no)
  =>
  (retract ?f)  
  (assert (diagnosis "双相II型障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-psychotic-symptoms-2 ""
  ?f <- (check-delusion-hallucination-history-2 yes)
  =>
  (retract ?f)
  (bind ?question "精神病性症状仅出现在躁狂或重性抑郁发作期间。(yes/no)?")
  (assert (check-psychotic-symptoms-2 (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::psychotic-bipolar-II-disorder ""
  ?f <- (check-psychotic-symptoms-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相II型障碍，伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::schizophrenia-psychotic-disorder-2 ""
  ?f <- (check-psychotic-symptoms-2 no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症谱系或其他精神病性障碍（参见用于鉴别诊断的妄想树形图或幻觉树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-cyclothymic-disorder ""
  ?f <- (check-hypomania-history no)
  =>
  (retract ?f)
  (bind ?question "2年以上的轻躁狂症状和周期性抑郁心境。(yes/no)?")
  (assert (check-cyclothymic-disorder (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::cyclothymic-disorder ""
  ?f <- (check-cyclothymic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "环性心境障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-periodic-depressive-mood ""
  ?f <- (check-cyclothymic-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生仅与周期性抑郁心境有关。(yes/no)?")
  (assert (check-periodic-depressive-mood (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::check-major-depressive-disorder ""
  ?f <- (check-periodic-depressive-mood yes)
  =>
  (retract ?f)
  (bind ?question "至少2周的抑郁心境，或兴趣减退，附加相关的特征性症状（如体重和食欲改变，睡眠改变，疲乏，自杀想法）。(yes/no)?")
  (assert (check-major-depressive-disorder (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::major-depressive-disorder ""
  ?f <- (check-major-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-persistent-depressive-disorder ""
  ?f <- (check-major-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "抑郁心境在至少2年的多数日子里出现，并伴有相关症状。(yes/no)?")
  (assert (check-persistent-depressive-disorder (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::persistent-depressive-disorder ""
  ?f <- (check-persistent-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "持续性抑郁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-premenstrual-dysphoric-disorder ""
  ?f <- (check-persistent-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "抑郁心境规律地在月经开始前1周出现，并在月经结束后的1周消失。(yes/no)?")
  (assert (check-premenstrual-dysphoric-disorder (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::premenstrual-dysphoric-disorder ""
  ?f <- (check-premenstrual-dysphoric-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "经前期烦躁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-disruptive-mood-dysregulation-disorder ""
  (or (check-periodic-depressive-mood no)
      (check-premenstrual-dysphoric-disorder no))
  =>
  (bind ?question "发生在严重的脾气爆发的背景下，与所处情境完全不相称，在爆发间期伴有持续的愤怒和易激惹。(yes/no)?")
  (assert (check-disruptive-mood-dysregulation-disorder (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::disruptive-mood-dysregulation-disorder ""
  ?f <- (check-disruptive-mood-dysregulation-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "破坏性心境失调障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-oppositional-defiant-disorder ""
  ?f <- (check-disruptive-mood-dysregulation-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生与争辩、对抗和报复的模式有关。(yes/no)?")
  (assert (check-oppositional-defiant-disorder (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::oppositional-defiant-disorder ""
  ?f <- (check-oppositional-defiant-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "对立违抗障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-borderline-personality-disorder ""
  ?f <- (check-oppositional-defiant-disorder no)
  =>
  (retract ?f)
  (bind ?question "以一种持续而普遍的模式出现，表现为人际关系、自我形象和情感不稳定并有明显的冲动，始于成年早期。(yes/no)?")
  (assert (check-borderline-personality-disorder (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::borderline-personality-disorder ""
  ?f <- (check-borderline-personality-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "边缘型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-antisocial-personality-disorder ""
  ?f <- (check-borderline-personality-disorder no)
  =>
  (retract ?f)
  (bind ?question "以一种持续而普遍的模式出现，表现为漠视并侵犯他人的权利，始于15岁。(yes/no)?")
  (assert (check-antisocial-personality-disorder (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::antisocial-personality-disorder ""
  ?f <- (check-antisocial-personality-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "反社会型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::check-dysfunction ""
  ?f <- (check-antisocial-personality-disorder no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的易激惹表现代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::check-poor-stressors-adjustment ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "对应激源适应不良的反应。(yes/no)?")
  (assert (check-poor-stressors-adjustment (yes-or-no-p ?question))))

(defrule IRRITABLE-MOOD::adjustment-disorder ""
  ?f <- (check-poor-stressors-adjustment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::specific-unspecific-bipolar-disorder ""
  ?f <- (check-poor-stressors-adjustment no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的双相及相关障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule IRRITABLE-MOOD::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”易激惹表现。"))
  (extract-ordered-facts)
  (halt))


;;;******************************
;;;* cc10: DEPRESSED-MOOD RULES *
;;;******************************
(defrule DEPRESSED-MOOD::subsystem-banner ""
  (chief-complaint "抑郁心境")
  =>
  (println "用于抑郁心境的决策树" crlf)
  (assert (check substance-use)))

(defrule DEPRESSED-MOOD::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::check-substance-use-impairment ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "高抑郁症状为主要临床表现并严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-impairment (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::substance-use-depressive-disorder ""
  ?f <- (check-substance-use-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的抑郁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::check-medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-medical-conditions-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::medical-conditions-depressive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-depressive-mood-duration ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "至少2周的抑郁心境或兴趣减退，附加相关的特征性症状（如体重和食欲改变、睡眠改变、疲乏和自杀想法）。(yes/no)?")
  (assert (check-depressive-mood-duration (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::check-mania-symptoms ""
  ?f <- (check-depressive-mood-duration yes)
  =>
  (retract ?f)
  (bind ?question "符合躁狂发作的诊断标准（即至少1周的心境高涨或膨胀，伴活动或精力增加，并有至少三个其他特征性症状，严重到引起明显的损害）。(yes/no)?")
  (assert (check-mania-symptoms (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::major-depressive-episode ""
  ?f <- (check-mania-symptoms no)
  =>
  (retract ?f)
  (println "重性抑郁发作")
  (assert (check mania-hypomania-impairment)))

(defrule DEPRESSED-MOOD::mania-hybrid-symptoms ""
  ?f <- (check-mania-symptoms yes)
  =>
  (retract ?f)
  (println "躁狂发作，伴混合特征。")
  (assert (check mania-hypomania-impairment)))

(defrule DEPRESSED-MOOD::check-mania-hypomania-impairment ""
  (or 
      (check-depressive-mood-duration no)
      (check mania-hypomania-impairment))
  =>
  (bind ?question "有临床意义的躁狂或轻躁狂发作。(yes/no)?")
  (assert (check-mania-hypomania-impairment (yes-or-no-p ?question))))

;;;check-mania-hypomania-impairment yes
(defrule DEPRESSED-MOOD::check-mania-symptoms-2 ""
  ?f <- (check-mania-hypomania-impairment yes)
  =>
  (retract ?f)
  (bind ?question "符合躁狂发作的诊断标准（即至少1周的心境高涨或膨胀，伴活动或精力增加，并有至少三个其他特征性症状，严重到引起明显的损害）。(yes/no)?")
  (assert (check-mania-symptoms-2 (yes-or-no-p ?question))))

;;;check-mania-symptoms-2 yes
(defrule DEPRESSED-MOOD::check-delusion-hallucination-history ""
  ?f <- (check-mania-symptoms-2 yes)
  =>
  (retract ?f)
  (bind ?question "妄想或幻觉史(yes/no)?")
  (assert (check-delusion-hallucination-history (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::bipolar-I-disorder ""
  ?f <- (check-delusion-hallucination-history no)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-psychotic-symptoms ""
  ?f <- (check-delusion-hallucination-history yes)
  =>
  (retract ?f)
  (bind ?question "精神病性症状仅出现在躁狂或重性抑郁发作期间。(yes/no)?")
  (assert (check-psychotic-symptoms (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::psychotic-bipolar-I-disorder ""
  ?f <- (check-psychotic-symptoms yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍，伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::schizophrenia-spectrum ""
  ?f <- (check-psychotic-symptoms no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症谱系或其他精神病性障碍（参见用于鉴别诊断的妄想树形图或幻觉树形图）。"))
  (extract-ordered-facts)
  (halt))

;;;check-mania-symptoms-2 no
(defrule DEPRESSED-MOOD::check-hypomania-symptoms ""
  ?f <- (check-mania-symptoms-2 no)
  =>
  (retract ?f)
  (bind ?question "符合轻躁狂发作的诊断标准（即至少4天的心境高涨或膨胀，伴活动或精力增加，并有至少三个其他特征性症状，但尚未严重到引起明显的损害）并在其他时候符合重性抑郁发作的诊断标准。(yes/no)?")
  (assert (check-hypomania-symptoms (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::check-delusion-hallucination-history-2 ""
  ?f <- (check-hypomania-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "妄想或幻觉史(yes/no)?")
  (assert (check-delusion-hallucination-history-2 (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::bipolar-II-disorder ""
  ?f <- (check-delusion-hallucination-history-2 no)
  =>
  (retract ?f)  
  (assert (diagnosis "双相II型障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-psychotic-symptoms-2 ""
  ?f <- (check-delusion-hallucination-history-2 yes)
  =>
  (retract ?f)
  (bind ?question "精神病性症状仅出现在躁狂或重性抑郁发作期间。(yes/no)?")
  (assert (check-psychotic-symptoms-2 (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::psychotic-bipolar-II-disorder ""
  ?f <- (check-psychotic-symptoms-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相II型障碍，伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::schizophrenia-spectrum-2 ""
  ?f <- (check-psychotic-symptoms-2 no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症谱系或其他精神病性障碍（参见用于鉴别诊断的妄想树形图或幻觉树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-cyclothymic-disorder ""
  ?f <- (check-hypomania-symptoms no)
  =>
  (retract ?f)
  (bind ?question "2年以上的轻躁狂症状和周期性抑郁心境。(yes/no)?")
  (assert (check-cyclothymic-disorder (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::cyclothymic-disorder ""
  ?f <- (check-cyclothymic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "环性心境障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::specific-unspecific-bipolar-disorder ""
  ?f <- (check-cyclothymic-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的双相及相关障碍。"))
  (extract-ordered-facts)
  (halt))

;;;check-mania-hypomania-impairment no
(defrule DEPRESSED-MOOD::check-major-depressive-episode ""
  ?f <- (check-mania-hypomania-impairment no)
  =>
  (retract ?f)
  (bind ?question "一次或更多次的重性抑郁发作，无躁狂或轻躁狂发作。(yes/no)?")
  (assert (check-major-depressive-episode (yes-or-no-p ?question))))

;;;check-major-depressive-episode no
(defrule DEPRESSED-MOOD::check-persistent-depressive-disorder ""
  ?f <- (check-major-depressive-episode no)
  =>
  (retract ?f)
  (bind ?question "抑郁心境在至少2年的多数日子里出现，并伴有相关症状。(yes/no)?")
  (assert (check-persistent-depressive-disorder (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::persistent-depressive-disorder ""
  ?f <- (check-persistent-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "持续性抑郁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-premenstrual-dysphoric-disorder ""
  ?f <- (check-persistent-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "抑郁心境规律地在月经开始前1周出现，并在月经结束后的1周消失。与有临床意义的痛苦有关，或干扰到工作、学业、日常社交活动或与他人的关系。(yes/no)?")
  (assert (check-premenstrual-dysphoric-disorder (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::premenstrual-dysphoric-disorder ""
  ?f <- (check-premenstrual-dysphoric-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "经前期烦躁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-other-psychotic-symptoms ""
  ?f <- (check-premenstrual-dysphoric-disorder no)
  =>
  (retract ?f)
  (bind ?question "抑郁或烦躁心境作为其他精神障碍的有关特征（如对患有强迫症感到“意志消沉”）。(yes/no)?")
  (assert (check-other-psychotic-symptoms (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::check-mood-disorders ""
  ?f <- (check-other-psychotic-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "有临床意义的心境紊乱。(yes/no)?")
  (assert (check-mood-disorders (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::specific-unspecific-depressive-disorder ""
  ?f <- (check-mood-disorders yes)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-dysfunction ""
  ?f <- (check-other-psychotic-symptoms no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的抑郁症状代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::check-stressors-adjustment ""
  (or (check-mood-disorders no)
      (check-dysfunction yes))
  =>
  (bind ?question "对心理社会应激源适应不良的反应。(yes/no)?")
  (assert (check-stressors-adjustment (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::adjustment-disorder-with-depressive-mood ""
  ?f <- (check-stressors-adjustment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍伴抑郁心境。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::specific-unspecific-depressive-disorder-2 ""
  ?f <- (check-stressors-adjustment no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”日常忧郁。"))
  (extract-ordered-facts)
  (halt))

;;;check-major-depressive-episode yes
(defrule DEPRESSED-MOOD::check-delusion-hallucination-history-3 ""
  ?f <- (check-major-depressive-episode yes)
  =>
  (retract ?f)
  (bind ?question "妄想或幻觉史(yes/no)?")
  (assert (check-delusion-hallucination-history-3 (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::check-long-course ""
  ?f <- (check-delusion-hallucination-history-3 no)
  =>
  (retract ?f)
  (bind ?question "发作病程为2年或更长。(yes/no)?")
  (assert (check-long-course (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::major-persistent-depressive-disorder ""
  ?f <- (check-long-course yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍，加上持续性抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::major-depressive-disorder ""
  ?f <- (check-long-course no)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-psychotic-major-depressive-disorder ""
  ?f <- (check-delusion-hallucination-history-3 yes)
  =>
  (retract ?f)
  (bind ?question "精神病性症状仅出现在重性抑郁发作期间。(yes/no)?")
  (assert (check-psychotic-major-depressive-disorder (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::schizophrenia-spectrum-3 ""
  ?f <- (check-psychotic-major-depressive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症谱系或其他精神病性障碍（参见用于鉴别诊断的妄想树形图或幻觉树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::check-long-course-2 ""
  ?f <- (check-psychotic-major-depressive-disorder yes)
  =>
  (retract ?f)
  (bind ?question "发作病程为2年或更长。(yes/no)?")
  (assert (check-long-course-2 (yes-or-no-p ?question))))

(defrule DEPRESSED-MOOD::psychotic-persistent-major-depressive-disorder ""
  ?f <- (check-long-course-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍伴精神病性特征，加上持续性抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule DEPRESSED-MOOD::psychotic-major-depressive-disorder ""
  ?f <- (check-long-course-2 no)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍，伴精神病性特征。"))
  (extract-ordered-facts)
  (halt))


;;;******************************************
;;;* cc11: SUICIDAL-IDEATION-BEHAVIOR RULES *
;;;******************************************
(defrule SUICIDAL-IDEATION-BEHAVIOR::subsystem-banner ""
  (chief-complaint "自杀观念或行为")
  =>
  (println "用于自杀观念或行为的决策树" crlf)
  (assert (check non-suicide)))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-non-suicide ""
  ?f <- (check non-suicide)
  =>
  (retract ?f)
  (bind ?question "无死亡愿望的自伤行为。(yes/no)?")
  (assert (check-non-suicide (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::non-suicide ""
  ?f <- (check-non-suicide yes)
  =>
  (retract ?f)  
  (assert (diagnosis "不是自杀行为（参见用于鉴别诊断的自伤或自残树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-delusion-hallucination ""
  ?f <- (check-non-suicide no)
  =>
  (retract ?f)
  (bind ?question "与妄想（如被魔鬼附体的妄想性坚信）相关或是对命令性幻觉的反应。(yes/no)?")
  (assert (check-delusion-hallucination (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::suicidal-psychotic-disorder ""
  ?f <- (check-delusion-hallucination yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神病性障碍（如精神分裂症）。参见用于鉴别诊断的妄想树形图或幻觉树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-depressive-symptoms-without-mania ""
  ?f <- (check-delusion-hallucination no)
  =>
  (retract ?f)
  (bind ?question "发生有临床意义的抑郁症状的背景下，不伴有任何躁狂症状。(yes/no)?")
  (assert (check-depressive-symptoms-without-mania (yes-or-no-p ?question))))

;;;check-depressive-symptoms-without-mania yes
(defrule SUICIDAL-IDEATION-BEHAVIOR::check-medical-conditions ""
  ?f <- (check-depressive-symptoms-without-mania yes)
  =>
  (retract ?f)
  (bind ?question "抑郁症状是由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::medical-conditions-depressive-disorder ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)  
  (assert (diagnosis "抑郁症状是由于一般躯体疾病的生理效应所致。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-substance-use ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "抑郁症状是由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::substance-use-depressive-disorder ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-depressive-mood ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "发生在抑郁心境或者兴趣或愉悦感减退的背景下，伴有特征性的抑郁症状。(yes/no)?")
  (assert (check-depressive-mood (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::major-depressive-disorder ""
  ?f <- (check-depressive-mood yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍，双相I型障碍或双相II型障碍，或分裂情感性障碍中的重性抑郁发作。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-persistent-depressive-disorder ""
  ?f <- (check-depressive-mood no)
  =>
  (retract ?f)
  (bind ?question "抑郁心境存在于至少2年的大多数日子里。(yes/no)?")
  (assert (check-persistent-depressive-disorder (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::persistent-depressive-disorder ""
  ?f <- (check-persistent-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "持续性抑郁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-premenstrual-dysphoric-disorder ""
  ?f <- (check-persistent-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "抑郁心境规律地在月经开始前1周出现，并在月经结束后的1周消失。(yes/no)?")
  (assert (check-premenstrual-dysphoric-disorder (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::premenstrual-dysphoric-disorder ""
  ?f <- (check-premenstrual-dysphoric-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "经前期烦躁障碍"))
  (extract-ordered-facts)
  (halt))

;;;check-depressive-symptoms-without-mania no
;;;check-premenstrual-dysphoric-disorder no
(defrule SUICIDAL-IDEATION-BEHAVIOR::check-hybrid-mania-depression ""
  (or (check-depressive-symptoms-without-mania no)
      (check-premenstrual-dysphoric-disorder no))
  =>
  (bind ?question "发生躁狂和抑郁症状混合的背景下。(yes/no)?")
  (assert (check-hybrid-mania-depression (yes-or-no-p ?question))))

;;;check-hybrid-mania-depression yes
(defrule SUICIDAL-IDEATION-BEHAVIOR::check-medical-conditions-2 ""
  ?f <- (check-hybrid-mania-depression yes)
  =>
  (retract ?f)
  (bind ?question "躁狂和抑郁症状是由于某种一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions-2 (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::medical-conditions-bipolar-disorder ""
  ?f <- (check-medical-conditions-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的双相障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-substance-use-2 ""
  ?f <- (check-medical-conditions-2 no)
  =>
  (retract ?f)
  (bind ?question "躁狂和抑郁症状是由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use-2 (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::substance-use-bipolar-disorder ""
  ?f <- (check-substance-use-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的双相障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-depressive-mood-2 ""
  ?f <- (check-substance-use-2 no)
  =>
  (retract ?f)
  (bind ?question "发生在抑郁心境或者兴趣或愉悦感减退的背景下，伴有特征性的抑郁症状。(yes/no)?")
  (assert (check-depressive-mood-2 (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::bipolar-I-disorder ""
  ?f <- (check-depressive-mood-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "在双相I型障碍中的躁狂发作伴混合特征。"))
  (extract-ordered-facts)
  (halt))

;;;check-hybrid-mania-depression no
;;;check-depressive-mood-2 no
(defrule SUICIDAL-IDEATION-BEHAVIOR::check-confusional-state ""
  (or (check-hybrid-mania-depression no)
      (check-depressive-mood-2 no))
  =>
  (bind ?question "与神经认知障碍中的意识错乱或缺乏判断力有关。(yes/no)?")
  (assert (check-confusional-state (yes-or-no-p ?question))))

;;;check-confusional-state yes
(defrule SUICIDAL-IDEATION-BEHAVIOR::check-delirium ""
  ?f <- (check-confusional-state yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-delirium (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::delirium ""
  ?f <- (check-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄，物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-neurocognitive-disorder ""
  ?f <- (check-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或 更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::neurocognitive-disorder ""
  ?f <- (check-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度神经认知障碍，物质/药物所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

;;;check-confusional-state no
;;;check-neurocognitive-disorder no
(defrule SUICIDAL-IDEATION-BEHAVIOR::check-substance-intoxication-withdrawal ""
  (or (check-confusional-state no)
      (check-neurocognitive-disorder no))
  =>
  (bind ?question "与物质中毒或物质戒断或药物副作用相关的脱抑制、失语或意识错乱。(yes/no)?")
  (assert (check-substance-intoxication-withdrawal (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::substance-intoxication-withdrawal ""
  ?f <- (check-substance-intoxication-withdrawal yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-disruptive-mood-dysregulation-disorder ""
  ?f <- (check-substance-intoxication-withdrawal no)
  =>
  (retract ?f)
  (bind ?question "与严重的、反复的脾气爆发有关，与所受到的挑衅严重不对称；在爆发间期有持续性的愤怒、易激惹心境；并起病于10岁前。(yes/no)?")
  (assert (check-disruptive-mood-dysregulation-disorder (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::disruptive-mood-dysregulation-disorder ""
  ?f <- (check-disruptive-mood-dysregulation-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "破坏性心境失调障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-conduct-antisocial-disorder ""
  ?f <- (check-disruptive-mood-dysregulation-disorder no)
  =>
  (retract ?f)
  (bind ?question "与易激惹、攻击性、冲动性和或法律问题相关。(yes/no)?")
  (assert (check-conduct-antisocial-disorder (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::conduct-antisocial-disorder ""
  ?f <- (check-conduct-antisocial-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "品行障碍，反社会型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-borderline-personality-disorder ""
  ?f <- (check-conduct-antisocial-disorder no)
  =>
  (retract ?f)
  (bind ?question "与一种害怕被抛弃、强烈愤怒和冲动控制不佳的慢性模式相关。(yes/no)?")
  (assert (check-borderline-personality-disorder (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::borderline-personality-disorder ""
  ?f <- (check-borderline-personality-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "边缘型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-facticious-disorder ""
  ?f <- (check-borderline-personality-disorder no)
  =>
  (retract ?f)
  (bind ?question "自杀观念或行为是伪装的。(yes/no)?")
  (assert (check-facticious-disorder (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::facticious-disorder ""
  ?f <- (check-facticious-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "做作性障碍，诈病。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-demoralized-state ""
  ?f <- (check-facticious-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生在与某种精神障碍或一般躯体疾病有关的严重意志消沉的背景下。(yes/no)?")
  (assert (check-demoralized-state (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::demoralized-psychotic-disorder ""
  ?f <- (check-demoralized-state yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神障碍加上第三部分的自杀行为障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::check-psychosocial-stressors ""
  ?f <- (check-demoralized-state no)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源的反应出现并且行为不能用其他特定的精神障碍来解释。(yes/no)?")
  (assert (check-psychosocial-stressors (yes-or-no-p ?question))))

(defrule SUICIDAL-IDEATION-BEHAVIOR::adjustment-disorder ""
  ?f <- (check-psychosocial-stressors yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SUICIDAL-IDEATION-BEHAVIOR::final ""
  ?f <- (check-psychosocial-stressors no)
  =>
  (retract ?f)  
  (assert (diagnosis "不必诊断精神障碍（如想要了结不治之症或其后果）。"))
  (extract-ordered-facts)
  (halt))


;;;***************************************
;;;* cc12: PSYCHOMOTOR-RETARDATION RULES *
;;;***************************************
(defrule PSYCHOMOTOR-RETARDATION::subsystem-banner ""
  (chief-complaint "精神运动性迟滞")
  =>
  (println "用于精神运动性迟滞的决策树" crlf)
  (assert (check substance-use)))

(defrule PSYCHOMOTOR-RETARDATION::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::check-neuroleptic-use ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "与神经阻滞剂的使用相关。(yes/no)?")
  (assert (check-neuroleptic-use (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::neuroleptic-use ""
  ?f <- (check-neuroleptic-use yes)
  =>
  (retract ?f)  
  (assert (diagnosis "神经阻滞剂所致的帕金森氏综合征，神经阻滞剂恶性综合征。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-substance-use-delirium ""
  ?f <- (check-neuroleptic-use no)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-substance-use-delirium (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::substance-use-delirium ""
  ?f <- (check-substance-use-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄，活动减退型。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-substance-use-neurocognitive-disorder ""
  ?f <- (check-substance-use-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-substance-use-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::substance-use-neurocognitive-disorder ""
  ?f <- (check-substance-use-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-substance-use-depressive-symptoms ""
  ?f <- (check-substance-use-neurocognitive-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生有严重抑郁症状的背景下。(yes/no)?")
  (assert (check-substance-use-depressive-symptoms (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::substance-use-depressive-disorder ""
  ?f <- (check-substance-use-depressive-symptoms yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的抑郁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use-depressive-symptoms no)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::check-medical-conditions-delirium ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-medical-conditions-delirium (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::medical-conditions-delirium ""
  ?f <- (check-medical-conditions-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄，活动减退型。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-medical-conditions-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-catatonic-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder no)
  =>
  (retract ?f)
  (bind ?question "紧张症性缄默加上至少两个其他的紧张症症状。(yes/no)?")
  (assert (check-catatonic-disorder (yes-or-no-p ?question))))


(defrule PSYCHOMOTOR-RETARDATION::catatonic-disorder ""
  ?f <- (check-catatonic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的紧张症障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-medical-conditions-depressive-disorder ""
  ?f <- (check-catatonic-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生在有严重抑郁症状的背景下。(yes/no)?")
  (assert (check-medical-conditions-depressive-disorder (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::medical-conditions-depressive-disorder ""
  ?f <- (check-medical-conditions-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::medical-conditions-symptoms ""
  ?f <- (check-medical-conditions-depressive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "一般躯体疾病的症状（例如甲状腺功能低下）。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-catatonia ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "与至少两个特征性的紧张症症状有关（如僵住、蜡样屈曲、违拗、作态、刻板运动、模仿言语）。(yes/no)?")
  (assert (check-catatonia (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::catatonia ""
  ?f <- (check-catatonia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "紧张症（参见用于鉴别诊断的紧张症症状树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-major-depressive-disorder ""
  ?f <- (check-catatonia no)
  =>
  (retract ?f)
  (bind ?question "发生在抑郁心境或者兴趣或愉悦感减退的背景下，伴有特征性的抑郁症状。(yes/no)?")
  (assert (check-major-depressive-disorder (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::major-depressive-disorder ""
  ?f <- (check-major-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍，双相I型障碍或双相II型障碍，或分裂情感性障碍中的重性抑郁发作。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::check-schizophrenia-spectrum ""
  ?f <- (check-major-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "与妄想、幻觉或言语瓦解有关。(yes/no)?")
  (assert (check-schizophrenia-spectrum (yes-or-no-p ?question))))

(defrule PSYCHOMOTOR-RETARDATION::schizophrenia-spectrum ""
  ?f <- (check-schizophrenia-spectrum yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症谱系或其他精神病性障碍（参见用于鉴别诊断的妄想树形图、幻觉树形图或言语紊乱树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule PSYCHOMOTOR-RETARDATION::final ""
  ?f <- (check-schizophrenia-spectrum no)
  =>
  (retract ?f)  
  (assert (diagnosis "精神运动活动的“正常”变异"))
  (extract-ordered-facts)
  (halt))



;;;***********************
;;;* cc13: ANXIETY RULES *
;;;***********************
(defrule ANXIETY::subsystem-banner ""
  (chief-complaint "焦虑")
  =>
  (println "用于焦虑的决策树" crlf)
  (assert (check substance-use)))

(defrule ANXIETY::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule ANXIETY::check-substance-use-delirium ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-substance-use-delirium (yes-or-no-p ?question))))

(defrule ANXIETY::substance-use-delirium ""
  ?f <- (check-substance-use-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-substance-use-anxiety-impairment ""
  ?f <- (check-substance-use-delirium no)
  =>
  (retract ?f)
  (bind ?question "焦虑症状为主要临床表现且严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-anxiety-impairment (yes-or-no-p ?question))))

(defrule ANXIETY::substance-use-anxiety ""
  ?f <- (check-substance-use-anxiety-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use-anxiety-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule ANXIETY::check-medical-conditions-delirium ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-medical-conditions-delirium (yes-or-no-p ?question))))

(defrule ANXIETY::medical-conditions-delirium ""
  ?f <- (check-medical-conditions-delirium yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-medical-conditions-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::medical-conditions-anxiety-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的焦虑障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-panic-attacks ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "突然发生的强烈的害怕和不适，在数分钟内达到高峰。(yes/no)?")
  (assert (check-panic-attacks (yes-or-no-p ?question))))

(defrule ANXIETY::panic-attacks ""
  ?f <- (check-panic-attacks yes)
  =>
  (retract ?f)  
  (assert (diagnosis "惊恐发作或有限症状发作（参见用于鉴别诊断的惊恐发作树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-panic-disorder ""
  ?f <- (check-panic-attacks no)
  =>
  (retract ?f)
  (bind ?question "反复、不可预期的有临床意义的惊恐发作。(yes/no)?")
  (assert (check-panic-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::panic-disorder ""
  ?f <- (check-panic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "惊恐障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-agoraphobia ""
  ?f <- (check-panic-disorder no)
  =>
  (retract ?f)
  (bind ?question "担心在某些地方出现惊恐发作或惊恐样症状时难以逃脱或令人尴尬，没有更广泛的担心。(yes/no)?")
  (assert (check-agoraphobia (yes-or-no-p ?question))))

(defrule ANXIETY::agoraphobia ""
  ?f <- (check-agoraphobia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "场所恐怖症"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-separation-anxiety-disorder ""
  ?f <- (check-agoraphobia no)
  =>
  (retract ?f)
  (bind ?question "对主要依恋对象分开感到焦虑或担心，没有更广泛的担心。(yes/no)?")
  (assert (check-separation-anxiety-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::separation-anxiety-disorder ""
  ?f <- (check-separation-anxiety-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "分离焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-social-anxiety-disorder ""
  ?f <- (check-separation-anxiety-disorder no)
  =>
  (retract ?f)
  (bind ?question "对暴露于受他人审视的社交情境感到焦虑或担心，没有更广泛的担心。(yes/no)?")
  (assert (check-social-anxiety-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::social-anxiety-disorder ""
  ?f <- (check-social-anxiety-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "社交焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-specific-phobia ""
  ?f <- (check-social-anxiety-disorder no)
  =>
  (retract ?f)
  (bind ?question "对暴露于可怕的物体（如蜘蛛）或情境（如接受注射，飞行）感到焦虑。(yes/no)?")
  (assert (check-specific-phobia (yes-or-no-p ?question))))

(defrule ANXIETY::specific-phobia ""
  ?f <- (check-specific-phobia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "特定恐怖症"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-medical-conditions-anxiety ""
  ?f <- (check-specific-phobia no)
  =>
  (retract ?f)
  (bind ?question "对健康和患有或获得某种严重疾病感到焦虑，没有更广泛的担心。(yes/no)?")
  (assert (check-medical-conditions-anxiety (yes-or-no-p ?question))))

(defrule ANXIETY::check-somatic-symptom-disorder ""
  ?f <- (check-medical-conditions-anxiety yes)
  =>
  (retract ?f)
  (bind ?question "躯体症状令人痛苦。(yes/no)?")
  (assert (check-somatic-symptom-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::somatic-symptom-disorder ""
  ?f <- (check-somatic-symptom-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "躯体症状障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-psychotic-disorder ""
  ?f <- (check-somatic-symptom-disorder no)
  =>
  (retract ?f)
  (bind ?question "对严重躯体疾病的信念达到妄想的强度。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::illness-anxiety-disorder ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "疾病焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::psychotic-disorder ""
  ?f <- (check-psychotic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神病性障碍（参见用于鉴别诊断的妄想树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-hoarding-disorder ""
  ?f <- (check-medical-conditions-anxiety no)
  =>
  (retract ?f)
  (bind ?question "对丢弃个人物品感到焦虑，导致积聚的物品堆满生活区域。(yes/no)?")
  (assert (check-hoarding-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::hoarding-disorder ""
  ?f <- (check-hoarding-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "囤积障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-body-dysmorphic-disorder ""
  ?f <- (check-hoarding-disorder no)
  =>
  (retract ?f)
  (bind ?question "对臆想的外貌缺陷感到焦虑或担心。(yes/no)?")
  (assert (check-body-dysmorphic-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::body-dysmorphic-disorder ""
  ?f <- (check-body-dysmorphic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "躯体变形障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-anxiety-thoughts ""
  ?f <- (check-body-dysmorphic-disorder no)
  =>
  (retract ?f)
  (bind ?question "焦虑与反复出现的担心、想法或思维反刍有关。(yes/no)?")
  (assert (check-anxiety-thoughts (yes-or-no-p ?question))))

(defrule ANXIETY::check-obsessive-compulsive-disorder ""
  ?f <- (check-anxiety-thoughts yes)
  =>
  (retract ?f)
  (bind ?question "反复出现的想法被体验为侵入性的、不需要的和自我排斥的。(yes/no)?")
  (assert (check-obsessive-compulsive-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::obsessive-compulsive-disorder ""
  ?f <- (check-obsessive-compulsive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "强迫症"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-generalized-anxiety-disorder ""
  ?f <- (check-obsessive-compulsive-disorder no)
  =>
  (retract ?f)
  (bind ?question "对多个事件或情境的过度担心和焦虑，持续至少6个月。(yes/no)?")
  (assert (check-generalized-anxiety-disorder (yes-or-no-p ?question))))

(defrule ANXIETY::generalized-anxiety-disorder ""
  ?f <- (check-generalized-anxiety-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "广泛性焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-trauma-stressors ""
  (or (check-anxiety-thoughts no)
      (check-generalized-anxiety-disorder no))
  =>
  (bind ?question "焦虑与暴露于严重的创伤性应激源有关。(yes/no)?")
  (assert (check-trauma-stressors (yes-or-no-p ?question))))

(defrule ANXIETY::check-stress-disorders ""
  ?f <- (check-trauma-stressors yes)
  =>
  (retract ?f)
  (bind ?question "有侵入症状、回避与创伤性应激源有关的刺激、认知和心境的负性改变、以及警觉性和活动的改变。(yes/no)?")
  (assert (check-stress-disorders (yes-or-no-p ?question))))

(defrule ANXIETY::check-course ""
  ?f <- (check-stress-disorders yes)
  =>
  (retract ?f)
  (bind ?question "病程超过1个月。(yes/no)?")
  (assert (check-course (yes-or-no-p ?question))))

(defrule ANXIETY::PTSD ""
  ?f <- (check-course yes)
  =>
  (retract ?f)  
  (assert (diagnosis "创伤后应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::acute-stress-disorder ""
  ?f <- (check-course no)
  =>
  (retract ?f)  
  (assert (diagnosis "急性应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-mania-hypomania-depression ""
  (or (check-trauma-stressors no)
      (check-stress-disorders no))
  =>
  (bind ?question "与躁狂发作、轻躁狂发作或重性抑郁发作有关的焦虑。(yes/no)?")
  (assert (check-mania-hypomania-depression (yes-or-no-p ?question))))

(defrule ANXIETY::anxiety-in-mania-hypomania-depression ""
  ?f <- (check-mania-hypomania-depression yes)
  =>
  (retract ?f)  
  (assert (diagnosis "在重性抑郁、双相I型障碍或双相II型障碍中的重性抑郁发作伴焦虑特征，在双相I型障碍中的躁狂发作伴焦虑特征，在双相I型或双相II型障碍中的轻躁狂发作伴焦虑特征。"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::check-dysfunction ""
  ?f <- (check-mania-hypomania-depression no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的焦虑症状代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule ANXIETY::check-psychosocial-stressors ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源的反应出现。(yes/no)?")
  (assert (check-psychosocial-stressors (yes-or-no-p ?question))))

(defrule ANXIETY::adjustment-disorder ""
  ?f <- (check-psychosocial-stressors yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍伴焦虑"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::specific-unspecific-anxiety-disorder ""
  ?f <- (check-psychosocial-stressors no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的焦虑障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule ANXIETY::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”焦虑"))
  (extract-ordered-facts)
  (halt))


;;;*****************************
;;;* cc14: PANIC-ATTACKS RULES *
;;;*****************************
(defrule PANIC-ATTACKS::subsystem-banner ""
  (chief-complaint "惊恐发作")
  =>
  (println "用于惊恐发作的决策树" crlf)
  (assert (check substance-use)))

(defrule PANIC-ATTACKS::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::check-substance-use-panic-attacks-impairment ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "惊恐发作为主要临床表现且严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-panic-attacks-impairment (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::substance-use-anxiety-disorder ""
  ?f <- (check-substance-use-panic-attacks-impairment yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use-panic-attacks-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::medical-conditions-anxiety-panic-attacks ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的焦虑障碍，伴惊恐发作。"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-panic-disorder ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "反复、不可预期的惊恐发作，伴有至少1个月的担心或适应不良的行为改变。(yes/no)?")
  (assert (check-panic-disorder (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::panic-disorder ""
  ?f <- (check-panic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "惊恐障碍"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-social-anxiety-panic-attacks ""
  ?f <- (check-panic-disorder no)
  =>
  (retract ?f)
  (bind ?question "惊恐发作的诱因是害怕在社交场合中的尴尬。(yes/no)?")
  (assert (check-social-anxiety-panic-attacks (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::social-anxiety-panic-attacks ""
  ?f <- (check-social-anxiety-panic-attacks yes)
  =>
  (retract ?f)  
  (assert (diagnosis "社交焦虑障碍伴惊恐发作"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-specific-phobia-panic-attacks ""
  ?f <- (check-social-anxiety-panic-attacks no)
  =>
  (retract ?f)
  (bind ?question "惊恐发作的诱因是害怕特定的物体（如蜘蛛）或情境（如高处、看见血液）。(yes/no)?")
  (assert (check-specific-phobia-panic-attacks (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::specific-phobia-panic-attacks ""
  ?f <- (check-specific-phobia-panic-attacks yes)
  =>
  (retract ?f)  
  (assert (diagnosis "特定恐怖症伴惊恐发作"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-separation-anxiety-panic-attacks ""
  ?f <- (check-specific-phobia-panic-attacks no)
  =>
  (retract ?f)
  (bind ?question "惊恐发作的诱因是害怕与主要依恋对象分离。(yes/no)?")
  (assert (check-separation-anxiety-panic-attacks (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::separation-anxiety-panic-attacks ""
  ?f <- (check-separation-anxiety-panic-attacks yes)
  =>
  (retract ?f)  
  (assert (diagnosis "分离焦虑障碍伴惊恐发作"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-stressors ""
  ?f <- (check-separation-anxiety-panic-attacks no)
  =>
  (retract ?f)
  (bind ?question "惊恐发作的诱因是暴露于与先前创伤经历相似的情境。同时有侵入症状、回避与创伤性应激源有关的刺激、认知和心境的负性改变，以及警觉性和活动的改变。(yes/no)?")
  (assert (check-stressors (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::check-stressors-duration ""
  ?f <- (check-stressors yes)
  =>
  (retract ?f)
  (bind ?question "病程超过1个月。(yes/no)?")
  (assert (check-stressors-duration (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::PTSD-panic-attacks ""
  ?f <- (check-stressors-duration yes)
  =>
  (retract ?f)  
  (assert (diagnosis "创伤后应激障碍伴惊恐发作"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::acute-stress-disorder-panic-attacks ""
  ?f <- (check-stressors-duration no)
  =>
  (retract ?f)  
  (assert (diagnosis "急性应激障碍伴惊恐发作"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-illness-anxiety-panic-attacks ""
  ?f <- (check-stressors no)
  =>
  (retract ?f)
  (bind ?question "惊恐发作的诱因是认为存在严重疾病的威胁。(yes/no)?")
  (assert (check-illness-anxiety-panic-attacks (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::illness-anxiety-disorder-panic-attacks ""
  ?f <- (check-illness-anxiety-panic-attacks yes)
  =>
  (retract ?f)  
  (assert (diagnosis "疾病焦虑障碍伴惊恐发作"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-obsessive-compulsive-disorder-panic-attacks ""
  ?f <- (check-illness-anxiety-panic-attacks no)
  =>
  (retract ?f)
  (bind ?question "惊恐发作的诱因是暴露于强迫性忧虑的关注点（如对污染有强迫思维的个体接触到灰尘）。(yes/no)?")
  (assert (check-obsessive-compulsive-disorder-panic-attacks (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::obsessive-compulsive-disorder-panic-attacks ""
  ?f <- (check-obsessive-compulsive-disorder-panic-attacks yes)
  =>
  (retract ?f)  
  (assert (diagnosis "强迫症伴惊恐发作"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-generalized-anxiety-panic-attacks ""
  ?f <- (check-obsessive-compulsive-disorder-panic-attacks no)
  =>
  (retract ?f)
  (bind ?question "惊恐发作的诱因是对许多事件或活动，如工作或学校表现，过度的焦虑和担心。(yes/no)?")
  (assert (check-generalized-anxiety-panic-attacks (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::generalized-anxiety-disorder-panic-attacks ""
  ?f <- (check-generalized-anxiety-panic-attacks yes)
  =>
  (retract ?f)  
  (assert (diagnosis "广泛性焦虑障碍伴惊恐发作"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::check-dysfunction ""
  ?f <- (check-generalized-anxiety-panic-attacks no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的周期性焦虑代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::check-psychosocial-stressors ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对应激源的反应出现。(yes/no)?")
  (assert (check-psychosocial-stressors (yes-or-no-p ?question))))

(defrule PANIC-ATTACKS::adjustment-disorder-anxiety ""
  ?f <- (check-psychosocial-stressors yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍伴焦虑"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::specific-unspecific-anxiety-disorder ""
  ?f <- (check-psychosocial-stressors no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的焦虑障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule PANIC-ATTACKS::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”与背景相符的惊恐发作（如对严重威胁的即刻反应）"))
  (extract-ordered-facts)
  (halt))


;;;**********************************
;;;* cc15: AVOIDANCE-BEHAVIOR RULES *
;;;**********************************
(defrule AVOIDANCE-BEHAVIOR::subsystem-banner ""
  (chief-complaint "回避行为")
  =>
  (println "用于回避行为的决策树" crlf)
  (assert (check avoidance-situations)))

(defrule AVOIDANCE-BEHAVIOR::check-avoidance-situations ""
  ?f <- (check avoidance-situations)
  =>
  (retract ?f)
  (bind ?question "回避两个或更多类型的情境（即公共交通、开放的空间、封闭的空间、排队或在人群中、独自外出）。(yes/no)?")
  (assert (check-avoidance-situations (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::check-agoraphobia ""
  ?f <- (check-avoidance-situations yes)
  =>
  (retract ?f)
  (bind ?question "对这些情景的回避是由于想到出现惊恐样症状时可能难以逃脱或可能无法获得帮助。(yes/no)?")
  (assert (check-agoraphobia (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::agoraphobia ""
  ?f <- (check-agoraphobia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "场所恐怖症"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-social-situations ""
  (or (check-avoidance-situations no)
      (check-agoraphobia no))
  =>
  (bind ?question "因为害怕尴尬而回避社交情境。(yes/no)?")
  (assert (check-social-situations (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::check-medical-conditions-anxiety ""
  ?f <- (check-social-situations yes)
  =>
  (retract ?f)
  (bind ?question "对患有其他躯体疾病（如帕金森氏病）感到尴尬。(yes/no)?")
  (assert (check-medical-conditions-anxiety (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::check-social-anxiety-disorder-impairment ""
  ?f <- (check-medical-conditions-anxiety yes)
  =>
  (retract ?f)
  (bind ?question "害怕、焦虑或回避是过度的。(yes/no)?")
  (assert (check-social-anxiety-disorder-impairment (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::none ""
  ?f <- (check-social-anxiety-disorder-impairment no)
  =>
  (retract ?f)  
  (assert (diagnosis "无精神障碍（情境式焦虑）"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::social-anxiety-disorder ""
  (or (check-medical-conditions-anxiety no)
      (check-social-anxiety-disorder-impairment yes))
  =>
  (assert (diagnosis "社交焦虑障碍（还要考虑回避型人格障碍）"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-specific-phobia ""
  ?f <- (check-social-situations no)
  =>
  (retract ?f)
  (bind ?question "回避特定的让人害怕的物体（如蜘蛛）或情境（如高处，看见血液）。(yes/no)?")
  (assert (check-specific-phobia (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::specific-phobia ""
  ?f <- (check-specific-phobia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "特定恐怖症"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-separation-anxiety-disorder ""
  ?f <- (check-specific-phobia no)
  =>
  (retract ?f)
  (bind ?question "个体回避与主要依恋对象产生分离的情境。(yes/no)?")
  (assert (check-separation-anxiety-disorder (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::separation-anxiety-disorder ""
  ?f <- (check-separation-anxiety-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "分离焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-avoidance-trauma ""
  ?f <- (check-separation-anxiety-disorder no)
  =>
  (retract ?f)
  (bind ?question "回避与创伤性事件有关的刺激。(yes/no)?")
  (assert (check-avoidance-trauma (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::check-avoidance-trauma-course ""
  ?f <- (check-avoidance-trauma yes)
  =>
  (retract ?f)
  (bind ?question "病程超过1个月。(yes/no)?")
  (assert (check-avoidance-trauma-course (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::PTSD ""
  ?f <- (check-avoidance-trauma-course yes)
  =>
  (retract ?f)  
  (assert (diagnosis "创伤后应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::acute-stress-disorder ""
  ?f <- (check-avoidance-trauma-course no)
  =>
  (retract ?f)  
  (assert (diagnosis "急性应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-obsessive-compulsive-disorder ""
  ?f <- (check-avoidance-trauma no)
  =>
  (retract ?f)
  (bind ?question "回避可能促发强迫思维或强迫行为的刺激（如污染、小刀）。(yes/no)?")
  (assert (check-obsessive-compulsive-disorder (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::obsessive-compulsive-disorder ""
  ?f <- (check-obsessive-compulsive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "强迫症"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-illness-anxiety-disorder ""
  ?f <- (check-obsessive-compulsive-disorder no)
  =>
  (retract ?f)
  (bind ?question "回避可能危害健康的情境（如拜访生病的家庭成员），因为这些情境会导致对严重疾病的先占观念。(yes/no)?")
  (assert (check-illness-anxiety-disorder (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::illness-anxiety-disorder ""
  ?f <- (check-illness-anxiety-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "疾病焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-psychotic-disorder ""
  ?f <- (check-illness-anxiety-disorder no)
  =>
  (retract ?f)
  (bind ?question "回避与妄想性害怕相关的情境（如不离开家是因为个体坚信自己是谋杀计划的目标）。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::psychotic-disorder ""
  ?f <- (check-psychotic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神病性障碍，如精神分裂症（参见用于鉴别诊断的妄想树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-depression-schizophrenia ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "回避与精力缺乏、快感缺失或意志减退相关。(yes/no)?")
  (assert (check-depression-schizophrenia (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::major-depressive-disorder-schizophrenia ""
  ?f <- (check-depression-schizophrenia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍，精神分裂症"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-sexual-dysfunctions ""
  ?f <- (check-depression-schizophrenia no)
  =>
  (retract ?f)
  (bind ?question "因为担心性活动表现不佳而回避与性有关的情境。(yes/no)?")
  (assert (check-sexual-dysfunctions (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::sexual-dysfunctions ""
  ?f <- (check-sexual-dysfunctions yes)
  =>
  (retract ?f)  
  (assert (diagnosis "性功能失调"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-eating-disorder ""
  ?f <- (check-sexual-dysfunctions no)
  =>
  (retract ?f)
  (bind ?question "回避食物，导致显著的体重减轻。(yes/no)?")
  (assert (check-eating-disorder (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::check-weight-increment-anxiety ""
  ?f <- (check-eating-disorder yes)
  =>
  (retract ?f)
  (bind ?question "伴有对体重增加或变胖的强烈恐惧。(yes/no)?")
  (assert (check-weight-increment-anxiety (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::anorexia ""
  ?f <- (check-weight-increment-anxiety yes)
  =>
  (retract ?f)  
  (assert (diagnosis "神经性厌食"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::avoidant-restrictive-food-intake-disorder ""
  ?f <- (check-weight-increment-anxiety no)
  =>
  (retract ?f)  
  (assert (diagnosis "回避性/限制性摄食障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-avoidant-personality-disorder ""
  ?f <- (check-eating-disorder no)
  =>
  (retract ?f)
  (bind ?question "与害怕负性评价相关的回避模式，起病于成年早期。(yes/no)?")
  (assert (check-avoidant-personality-disorder (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::avoidant-personality-disorder ""
  ?f <- (check-avoidant-personality-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "回避型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::check-dysfunction ""
  ?f <- (check-avoidant-personality-disorder no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的回避代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::check-psychosocial-stressors ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对应激源的反应出现。(yes/no)?")
  (assert (check-psychosocial-stressors (yes-or-no-p ?question))))

(defrule AVOIDANCE-BEHAVIOR::adjustment-disorder ""
  ?f <- (check-psychosocial-stressors yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::specific-unspecific-anxiety-disorder ""
  ?f <- (check-psychosocial-stressors no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的焦虑障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule AVOIDANCE-BEHAVIOR::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”回避行为"))
  (extract-ordered-facts)
  (halt))


;;;*********************************************
;;;* cc16: TRAUMA-PSYCHOSOCIAL-STRESSORS RULES *
;;;*********************************************
(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::subsystem-banner ""
  (chief-complaint "病因涉及创伤或心理社会应激源")
  =>
  (println "用于病因涉及创伤或心理社会应激源的决策树" crlf)
  (assert (check traumatic-stressors)))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-traumatic-stressors ""
  ?f <- (check traumatic-stressors)
  =>
  (retract ?f)
  (bind ?question "暴露于创伤性应激源（如，危及生命的情境）。(yes/no)?")
  (assert (check-traumatic-stressors (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-characteristic-reponses ""
  ?f <- (check-traumatic-stressors yes)
  =>
  (retract ?f)
  (bind ?question "特征性的反应为存在侵入症状、回避与事件有关的刺激、认知和心境的负性改变以及警觉性和活动的改变。(yes/no)?")
  (assert (check-characteristic-reponses (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-trauma-duration ""
  ?f <- (check-characteristic-reponses yes)
  =>
  (retract ?f)
  (bind ?question "持续至少1个月。(yes/no)?")
  (assert (check-trauma-duration (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::PTSD ""
  ?f <- (check-trauma-duration yes)
  =>
  (retract ?f)  
  (assert (diagnosis "创伤后应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::acute-stress-disorder ""
  ?f <- (check-trauma-duration no)
  =>
  (retract ?f)  
  (assert (diagnosis "急性应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-extreme-lack-of-care ""
  (or (check-traumatic-stressors no)
      (check-characteristic-reponses no))
  =>
  (bind ?question "有极度缺乏照料的历史，例如，持续的社交忽视或剥夺，主要照料者的反复变更或成长环境严重限制了选择性依恋关系的形成。(yes/no)?")
  (assert (check-extreme-lack-of-care (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-emotional-withdrawal-disturbance ""
  ?f <- (check-extreme-lack-of-care yes)
  =>
  (retract ?f)
  (bind ?question "对成人照料者表现出抑制性的情感退缩行为模式并有持续的社交和情绪紊乱（如很少有情感反应，原因不明的易激惹、悲伤或害怕）。(yes/no)?")
  (assert (check-emotional-withdrawal-disturbance (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::reactive-attachment-disorder ""
  ?f <- (check-emotional-withdrawal-disturbance yes)
  =>
  (retract ?f)  
  (assert (diagnosis "反应性依恋障碍"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-disinhibited-social-engagement-disorder ""
  ?f <- (check-emotional-withdrawal-disturbance no)
  =>
  (retract ?f)
  (bind ?question "一种与陌生成年人接近中缺乏含蓄的模式，表现出过于随便的言语或肢体行为，而且愿意与陌生成年人一起离开。(yes/no)?")
  (assert (check-disinhibited-social-engagement-disorder (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::disinhibited-social-engagement-disorder ""
  ?f <- (check-disinhibited-social-engagement-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "脱抑制性社会参与障碍"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-brief-psychotic-disorder ""
  (or (check-extreme-lack-of-care no)
      (check-disinhibited-social-engagement-disorder no))
  =>
  (bind ?question "精神病性疾病作为对显著应激源的反应，持续不到1个月。(yes/no)?")
  (assert (check-brief-psychotic-disorder (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::brief-psychotic-disorder ""
  ?f <- (check-brief-psychotic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "短暂精神病性障碍，伴显著的应激源。"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-dissociative-amnesia ""
  ?f <- (check-brief-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "在暴露于应激源后，无法回忆起重要的个人信息。(yes/no)?")
  (assert (check-dissociative-amnesia (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::dissociative-amnesia ""
  ?f <- (check-dissociative-amnesia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "分离性遗忘症"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-convertion-disorder ""
  ?f <- (check-dissociative-amnesia no)
  =>
  (retract ?f)
  (bind ?question "在暴露于应激源后，出现自主运动或感觉功能发生改变的症状。(yes/no)?")
  (assert (check-convertion-disorder (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::convertion-disorder ""
  ?f <- (check-convertion-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "转换障碍伴心理应激源"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-bereavement ""
  ?f <- (check-convertion-disorder no)
  =>
  (retract ?f)
  (bind ?question "应激源是所爱之人的死亡。(yes/no)?")
  (assert (check-bereavement (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-bereavement-duration ""
  ?f <- (check-bereavement yes)
  =>
  (retract ?f)
  (bind ?question "持续的渴望/想念逝者，剧烈的悲伤和痛苦，沉湎于逝者或死亡时的情境，持续至少12个月。(yes/no)?")
  (assert (check-bereavement-duration (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::persistent-complex-bereavement-disorder ""
  ?f <- (check-bereavement-duration yes)
  =>
  (retract ?f)  
  (assert (diagnosis "第三部分：持续性复杂丧痛障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-specific-psychotic-disorder ""
  (or (check-bereavement no)
      (check-bereavement-duration no))
  =>
  (bind ?question "症状是对应激源的反应，符合某种特定的精神障碍的诊断标准（而非适应障碍）。(yes/no)?")
  (assert (check-specific-psychotic-disorder (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::specific-psychotic-disorder ""
  ?f <- (check-specific-psychotic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "特定的精神障碍（如重性抑郁障碍）。"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::check-adjustment-disorder ""
  ?f <- (check-specific-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "适应不良的反应并超出预期水平。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule TRAUMA-PSYCHOSOCIAL-STRESSORS::final ""
  ?f <- (check-adjustment-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "对应激源的“正常”反应"))
  (extract-ordered-facts)
  (halt))


;;;*************************************************************
;;;* cc17: SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY RULES *
;;;*************************************************************
(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::subsystem-banner ""
  (chief-complaint "躯体主诉或疾病/外貌焦虑")
  =>
  (println "用于躯体主诉或疾病/外貌焦虑的决策树" crlf)
  (assert (check somatic-complaints)))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-somatic-complaints ""
  ?f <- (check somatic-complaints)
  =>
  (retract ?f)
  (bind ?question "躯体症状是故意产生或伪装的。(yes/no)?")
  (assert (check-somatic-complaints (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-somatic-complaints-facticious-disorder ""
  ?f <- (check-somatic-complaints yes)
  =>
  (retract ?f)
  (bind ?question "即使在没有明显外部奖赏的情况下，欺骗行为也非常明显。(yes/no)?")
  (assert (check-somatic-complaints-facticious-disorder (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::somatic-complaints-facticious-disorder ""
  ?f <- (check-somatic-complaints-facticious-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "做作性障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::malinger ""
  ?f <- (check-somatic-complaints-facticious-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "诈病"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-substance-use ""
  ?f <- (check-somatic-complaints no)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的直接生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-somatic-complaint-delusion ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "与涉及身体功能或感觉的妄想有关。(yes/no)?")
  (assert (check-somatic-complaint-delusion (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-convertion-disorder ""
  ?f <- (check-somatic-complaint-delusion no)
  =>
  (retract ?f)
  (bind ?question "出现影响自主运动或感觉功能的症状或缺陷，不能用神经系统或其他医学疾病或精神障碍来更好地解释。(yes/no)?")
  (assert (check-convertion-disorder (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::convertion-disorder ""
  ?f <- (check-convertion-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "转换障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-body-dysmorphic-disorder ""
  ?f <- (check-convertion-disorder no)
  =>
  (retract ?f)
  (bind ?question "沉湎于臆想的身体外貌上的缺陷或瑕疵，但他人观察不到。(yes/no)?")
  (assert (check-body-dysmorphic-disorder (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::body-dysmorphic-disorder ""
  ?f <- (check-body-dysmorphic-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "躯体变形障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-panic-attacks ""
  ?f <- (check-body-dysmorphic-disorder no)
  =>
  (retract ?f)
  (bind ?question "作为突发的强烈害怕或不适表现的一部分，在数分钟内达到高峰。(yes/no)?")
  (assert (check-panic-attacks (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::panic-attacks ""
  ?f <- (check-panic-attacks yes)
  =>
  (retract ?f)  
  (assert (diagnosis "惊恐发作（参见用于鉴别诊断的惊恐发作树形图）"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-anxiety-disorder ""
  ?f <- (check-panic-attacks no)
  =>
  (retract ?f)
  (bind ?question "躯体症状（如口干、心悸）伴随焦虑，是某种焦虑障碍表现的一部分。(yes/no)?")
  (assert (check-anxiety-disorder (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::anxiety-disorder ""
  ?f <- (check-anxiety-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "焦虑障碍（参见用于鉴别诊断的焦虑树形图）"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-health-anxiety ""
  ?f <- (check-anxiety-disorder no)
  =>
  (retract ?f)
  (bind ?question "对健康的高度焦虑。(yes/no)?")
  (assert (check-health-anxiety (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-somatic-symptom-disorder ""
  ?f <- (check-health-anxiety yes)
  =>
  (retract ?f)
  (bind ?question "伴有一个或多个令人痛苦或扰乱日常生活的躯体症状。(yes/no)?")
  (assert (check-somatic-symptom-disorder (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-indulging-in-illness ""
  ?f <- (check-somatic-symptom-disorder no)
  =>
  (retract ?f)
  (bind ?question "沉湎于患有或获得某种严重疾病。(yes/no)?")
  (assert (check-indulging-in-illness (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-illness-delusion ""
  ?f <- (check-indulging-in-illness yes)
  =>
  (retract ?f)
  (bind ?question "对患有严重疾病的信念达到妄想的强度。(yes/no)?")
  (assert (check-illness-delusion (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::psychotic-disorder ""
  (or (check-somatic-complaint-delusion yes)
      (check-illness-delusion yes))
  =>
  (assert (diagnosis "精神病性障碍（参见用于鉴别诊断的妄想树形图）。"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::illness-anxiety-disorder ""
  ?f <- (check-illness-delusion no)
  =>
  (retract ?f)  
  (assert (diagnosis "疾病焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-somatic-symptoms ""
  (or (check-health-anxiety no)
      (check-indulging-in-illness no))
  =>
  (bind ?question "有一个或多个令人痛苦或扰乱日常生活的躯体症状。(yes/no)?")
  (assert (check-somatic-symptoms (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-somatic-symptom-disorder-2 ""
  ?f <- (check-somatic-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "伴有与疾病严重性不相称的想法或对症状投入过多的时间和精力。(yes/no)?")
  (assert (check-somatic-symptom-disorder-2 (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::somatic-symptom-disorder ""
  (or (check-somatic-symptom-disorder yes)
      (check-somatic-symptom-disorder-2 yes))
  =>
  (assert (diagnosis "躯体症状障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-somatic-psychological-factors ""
  ?f <- (check-somatic-symptom-disorder-2 no)
  =>
  (retract ?f)
  (bind ?question "存在一般躯体疾病，及负性影响躯体疾病的心理因素。(yes/no)?")
  (assert (check-somatic-psychological-factors (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::psychological-factors ""
  ?f <- (check-somatic-psychological-factors yes)
  =>
  (retract ?f)  
  (assert (diagnosis "影响其他躯体疾病的心理因素"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::somatic-factors ""
  ?f <- (check-somatic-psychological-factors no)
  =>
  (retract ?f)  
  (assert (diagnosis "一般躯体疾病（无精神障碍）。"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-dysfunction ""
  ?f <- (check-somatic-symptoms no)
  =>
  (retract ?f)
  (bind ?question "有临床意义的躯体主诉干扰了功能并代表了个体在心理上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::check-adjustment-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源的反应出现。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::specific-unspecific-somatic-symptom-disorder ""
  ?f <- (check-adjustment-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的躯体症状及相关障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SOMATIC-COMPLAINTS-ILLNESS-APPEARANCE-ANXIETY::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”日常疼痛和痛苦"))
  (extract-ordered-facts)
  (halt))


;;;*******************************
;;;* cc18: EATING-BEHAVIOR RULES *
;;;*******************************
(defrule EATING-BEHAVIOR::subsystem-banner ""
  (chief-complaint "食欲改变或异常的进食行为")
  =>
  (println "用于食欲改变或异常的进食行为的决策树" crlf)
  (assert (check appetite-weight-loss)))

(defrule EATING-BEHAVIOR::check-appetite-weight-loss ""
  ?f <- (check appetite-weight-loss)
  =>
  (retract ?f)
  (bind ?question "食欲下降、体重减轻或不能预期地增加体重。(yes/no)?")
  (assert (check-appetite-weight-loss (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::check-general-somatic-disease ""
  ?f <- (check-appetite-weight-loss yes)
  =>
  (retract ?f)
  (bind ?question "完全可以用一般躯体疾病（如癌症）的生理效应来解释。(yes/no)?")
  (assert (check-general-somatic-disease (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::general-somatic-disease ""
  ?f <- (check-general-somatic-disease yes)
  =>
  (retract ?f)  
  (assert (diagnosis "病因上的一般躯体疾病"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-substance-use-disorder ""
  ?f <- (check-general-somatic-disease no)
  =>
  (retract ?f)
  (bind ?question "完全可以用物质使用（如可卡因）或药物的副作用来解释。(yes/no)?")
  (assert (check-substance-use-disorder (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::substance-use-disorder ""
  ?f <- (check-substance-use-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质相关障碍，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-delusion-hallucination-response ""
  ?f <- (check-substance-use-disorder no)
  =>
  (retract ?f)
  (bind ?question "不进食是对妄想（如害怕食物有毒）或幻觉（如命令性幻觉要求不能进食）的反应。(yes/no)?")
  (assert (check-delusion-hallucination-response (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::psychotic-disorder ""
  ?f <- (check-delusion-hallucination-response yes)
  =>
  (retract ?f)  
  (assert (diagnosis "精神病性障碍（如精神分裂症）。参见用于鉴别诊断的妄想树形图或幻觉树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-depressive-disorder ""
  ?f <- (check-delusion-hallucination-response no)
  =>
  (retract ?f)
  (bind ?question "发生在抑郁症状的背景下。(yes/no)?")
  (assert (check-depressive-disorder (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::depressive-disorder ""
  ?f <- (check-depressive-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍，双相I型障碍或双相II型障碍，或分裂情感性障碍中的重性抑郁发作；持续性抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-bipolar-disorder ""
  ?f <- (check-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生在躁狂发作的背景下，继发于活动增加和对规律进餐时间的忽视。(yes/no)?")
  (assert (check-bipolar-disorder (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::bipolar-disorder ""
  ?f <- (check-bipolar-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍或分裂情感性障碍中的躁狂发作。"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-anorexia-nervosa ""
  ?f <- (check-bipolar-disorder no)
  =>
  (retract ?f)
  (bind ?question "伴有对体重增加或发胖的强烈恐惧。(yes/no)?")
  (assert (check-anorexia-nervosa (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::anorexia-nervosa ""
  ?f <- (check-anorexia-nervosa yes)
  =>
  (retract ?f)  
  (assert (diagnosis "神经性厌食"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-rumination-disorder ""
  ?f <- (check-anorexia-nervosa no)
  =>
  (retract ?f)
  (bind ?question "与反复的食物反流有关，反流的食物可能被再咀嚼、再吞咽或吐出。(yes/no)?")
  (assert (check-rumination-disorder (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::rumination-disorder ""
  ?f <- (check-rumination-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "反刍障碍"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-avoidant-restrictive-eating-disorder ""
  ?f <- (check-rumination-disorder no)
  =>
  (retract ?f)
  (bind ?question "对进食缺乏兴趣，基于食物的感官特征回避食物，或担心进食的不良后果（如噎住）。(yes/no)?")
  (assert (check-avoidant-restrictive-eating-disorder (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::avoidant-restrictive-eating-disorder ""
  ?f <- (check-avoidant-restrictive-eating-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "回避性/限制性摄食障碍"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-appetite-weight-increment ""
  (or (check-appetite-weight-loss no)
      (check-avoidant-restrictive-eating-disorder no))
  =>
  (bind ?question "食欲增长或体重增加（并非暴食所致）。(yes/no)?")
  (assert (check-appetite-weight-increment (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::check-general-somatic-disease-2 ""
  ?f <- (check-appetite-weight-increment yes)
  =>
  (retract ?f)
  (bind ?question "完全可以用某种一般躯体疾病（如甲状腺功能低下）的生理效应或肥胖来解释。(yes/no)?")
  (assert (check-general-somatic-disease-2 (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::general-somatic-disease-2 ""
  ?f <- (check-general-somatic-disease-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "病因上的一般躯体疾病"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-substance-use-disorder-2 ""
  ?f <- (check-general-somatic-disease-2 no)
  =>
  (retract ?f)
  (bind ?question "完全可以用物质使用（如大麻中毒、可卡因戒断）或药物的副作用来解释。(yes/no)?")
  (assert (check-substance-use-disorder-2 (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::substance-use-disorder-2 ""
  ?f <- (check-substance-use-disorder-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "物质相关障碍，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-depressive-disorder-2 ""
  ?f <- (check-substance-use-disorder-2 no)
  =>
  (retract ?f)
  (bind ?question "发生在抑郁症状的背景下。(yes/no)?")
  (assert (check-depressive-disorder-2 (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::depressive-disorder-2 ""
  ?f <- (check-depressive-disorder-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "重性抑郁障碍，双相I型障碍或双相II型障碍，或分裂情感性障碍中的重性抑郁发作；持续性抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-binge-eating ""
  (or (check-appetite-weight-increment no)
      (check-depressive-disorder-2 no))
  =>
  (bind ?question "暴食。(yes/no)?")
  (assert (check-binge-eating (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::check-abnormal-low-weight ""
  ?f <- (check-binge-eating yes)
  =>
  (retract ?f)
  (bind ?question "伴有异常的低体重。(yes/no)?")
  (assert (check-abnormal-low-weight (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::anorexia-nervosa-2 ""
  ?f <- (check-abnormal-low-weight yes)
  =>
  (retract ?f)  
  (assert (diagnosis "神经性厌食"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-frequent-binge-eating ""
  ?f <- (check-abnormal-low-weight no)
  =>
  (retract ?f)
  (bind ?question "反复而频繁的暴食。(yes/no)?")
  (assert (check-frequent-binge-eating (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::check-vomiting ""
  ?f <- (check-frequent-binge-eating yes)
  =>
  (retract ?f)
  (bind ?question "伴有规律的、不适当的代偿行为（如引吐）。(yes/no)?")
  (assert (check-vomiting (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::bulimia-nervosa ""
  ?f <- (check-vomiting yes)
  =>
  (retract ?f)  
  (assert (diagnosis "神经性贪食"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-binge-eating-disorder ""
  ?f <- (check-vomiting no)
  =>
  (retract ?f)
  (bind ?question "暴食伴有症状如进食直到有不适的饱腹感或在没有感到饥饿时进食，因感到尴尬而单独进食，以及感到厌恶、抑郁或内疚。(yes/no)?")
  (assert (check-binge-eating-disorder (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::binge-eating-disorder ""
  ?f <- (check-binge-eating-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "暴食障碍"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-borderline-personality-disorder ""
  (or (check-frequent-binge-eating no)
      (check-binge-eating-disorder no))
  =>
  (bind ?question "作为一种冲动、心境失调和身份紊乱的模式出现，起病于成年早期。(yes/no)?")
  (assert (check-borderline-personality-disorder (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::borderline-personality-disorder ""
  ?f <- (check-borderline-personality-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "边缘型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-rumination-disorder-2 ""
  (or (check-binge-eating no)
      (check-borderline-personality-disorder no))
  =>
  (bind ?question "与反复的食物反流有关，反流的食物可能被再咀嚼、再吞咽或吐出。(yes/no)?")
  (assert (check-rumination-disorder-2 (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::rumination-disorder-2 ""
  ?f <- (check-rumination-disorder-2 yes)
  =>
  (retract ?f)  
  (assert (diagnosis "反刍障碍"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-allotriophagia ""
  ?f <- (check-rumination-disorder-2 no)
  =>
  (retract ?f)
  (bind ?question "持续进食非营养性、非食用性的物质。(yes/no)?")
  (assert (check-allotriophagia (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::allotriophagia ""
  ?f <- (check-allotriophagia yes)
  =>
  (retract ?f)  
  (assert (diagnosis "异食癖"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::check-dysfunction ""
  ?f <- (check-allotriophagia no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的体重改变或病理性进食行为代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::check-adjustment-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源的反应出现。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule EATING-BEHAVIOR::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes)
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::specific-unspecific-eating-disorder ""
  ?f <- (check-adjustment-disorder no)
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的喂食或进食障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule EATING-BEHAVIOR::final ""
  ?f <- (check-dysfunction no)
  =>
  (retract ?f)  
  (assert (diagnosis "进食行为或体重的“正常变异”（如一时狂热的节食）。"))
  (extract-ordered-facts)
  (halt))


;;;************************
;;;* cc19: INSOMNIA RULES *
;;;************************
(defrule INSOMNIA::subsystem-banner ""
  (chief-complaint "失眠")
  =>
  (println "用于失眠的决策树" crlf)
  (assert (check substance-use)))

(defrule INSOMNIA::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule INSOMNIA::check-substance-use-impairment ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "失眠是主要临床表现且严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-impairment (yes-or-no-p ?question))))

(defrule INSOMNIA::substance-ues-sleep-disorder-insomnia ""
  ?f <- (check-substance-use-impairment yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的睡眠障碍，失眠型。"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use-impairment no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-narcolepsy-symptoms ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "反复发生不可抗拒的睡眠需要伴猝倒发作，下丘脑分泌素缺乏，典型的夜间多导睡眠图发现或典型的多次睡眠潜伏期测试发现。(yes/no)?")
  (assert (check-narcolepsy-symptoms (yes-or-no-p ?question))))

(defrule INSOMNIA::check-insomnia-in-narcolepsy ""
  ?f <- (check-narcolepsy-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "失眠仅出现在发作性睡病期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-insomnia-in-narcolepsy (yes-or-no-p ?question))))

(defrule INSOMNIA::narcolepsy ""
  ?f <- (check-insomnia-in-narcolepsy yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "发作性睡病"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-polysomnographic-evidence ""
  (or (check-narcolepsy-symptoms no)
      (check-insomnia-in-narcolepsy no))
  =>
  (bind ?question "伴有以下多导睡眠图的证据，即每小时睡眠至少有5次阻塞性呼吸暂停或低通气，每小时睡眠至少有5次中枢性呼吸暂停，或与二氧化碳水平升高有关的呼吸次数减少。(yes/no)?")
  (assert (check-polysomnographic-evidence (yes-or-no-p ?question))))

(defrule INSOMNIA::check-insomnia-in-sleep-breathing ""
  ?f <- (check-polysomnographic-evidence yes)
  =>
  (retract ?f)
  (bind ?question "失眠仅出现在与呼吸相关的睡眠障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-insomnia-in-sleep-breathing (yes-or-no-p ?question))))

(defrule INSOMNIA::sleep-breathing-disorder ""
  ?f <- (check-insomnia-in-sleep-breathing yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "与呼吸相关的睡眠障碍（即阻塞性睡眠呼吸暂停低通气、中枢性睡眠呼吸暂停、睡眠相关的通气不足）"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-sleep-walking-terrors ""
  (or (check-polysomnographic-evidence no)
      (check-insomnia-in-sleep-breathing no))
  =>
  (bind ?question "由于睡行或睡惊症状所致。(yes/no)?")
  (assert (check-sleep-walking-terrors (yes-or-no-p ?question))))

(defrule INSOMNIA::check-insomnia-in-NREM ""
  ?f <- (check-sleep-walking-terrors yes)
  =>
  (retract ?f)
  (bind ?question "失眠仅出现在非快速眼动睡眠唤醒障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-insomnia-in-NREM (yes-or-no-p ?question))))

(defrule INSOMNIA::non-REM-sleep-arousal-disorder ""
  ?f <- (check-insomnia-in-NREM yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "非快速眼动睡眠唤醒障碍"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-dreams ""
  (or (check-sleep-walking-terrors no)
      (check-insomnia-in-NREM no))
  =>
  (bind ?question "由于存在延长的、极端令人烦躁和记忆完好的梦境而反复觉醒。(yes/no)?")
  (assert (check-dreams (yes-or-no-p ?question))))

(defrule INSOMNIA::check-insomnia-in-nightmare ""
  ?f <- (check-dreams yes)
  =>
  (retract ?f)
  (bind ?question "失眠仅出现在梦魇障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-insomnia-in-nightmare (yes-or-no-p ?question))))

(defrule INSOMNIA::nightmare-disorder ""
  ?f <- (check-insomnia-in-nightmare yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "梦魇障碍"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-REM ""
  (or (check-dreams no)
      (check-insomnia-in-nightmare no))
  =>
  (bind ?question "睡眠期间反复从快速眼动睡眠中觉醒，伴有发声或复杂的运动行为。(yes/no)?")
  (assert (check-REM (yes-or-no-p ?question))))

(defrule INSOMNIA::check-insomnia-in-REM ""
  ?f <- (check-REM yes)
  =>
  (retract ?f)
  (bind ?question "失眠仅出现在快速眼动睡眠行为障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-insomnia-in-REM (yes-or-no-p ?question))))

(defrule INSOMNIA::REM-sleep-behavior-disorder ""
  ?f <- (check-insomnia-in-REM yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "快速眼动睡眠行为障碍"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-restless-legs-syndrome ""
  (or (check-REM no)
      (check-insomnia-in-REM no))
  =>
  (bind ?question "由于存在移动双腿的冲动，对不愉快的感觉做出反应。(yes/no)?")
  (assert (check-restless-legs-syndrome (yes-or-no-p ?question))))

(defrule INSOMNIA::check-insomnia-in-restless-legs-syndrome ""
  ?f <- (check-restless-legs-syndrome yes)
  =>
  (retract ?f)
  (bind ?question "失眠仅出现在不安腿综合征期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-insomnia-in-restless-legs-syndrome (yes-or-no-p ?question))))

(defrule INSOMNIA::restless-legs-syndrome ""
  ?f <- (check-insomnia-in-restless-legs-syndrome yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "不安腿综合征"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-circadian-rhythm ""
  (or (check-restless-legs-syndrome no)
      (check-insomnia-in-restless-legs-syndrome no))
  =>
  (bind ?question "由于个体的时间表和自然的睡眠觉醒模式之间不匹配。(yes/no)?")
  (assert (check-circadian-rhythm (yes-or-no-p ?question))))

(defrule INSOMNIA::check-insomnia-in-circadian-rhythm ""
  ?f <- (check-circadian-rhythm yes)
  =>
  (retract ?f)
  (bind ?question "失眠仅出现在昼夜节律睡眠觉醒障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-insomnia-in-circadian-rhythm (yes-or-no-p ?question))))

(defrule INSOMNIA::circadian-rhythm-sleep-wake-disorder ""
  ?f <- (check-insomnia-in-circadian-rhythm yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "昼夜节律睡眠-觉醒障碍（即延迟睡眠时相型，提前睡眠时相型，不规律的睡眠觉醒型，非24小时睡眠-觉醒型，倒班工作型，未特定型）。"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-psychotic-insomnia ""
  (or (check-circadian-rhythm no)
      (check-insomnia-in-circadian-rhythm no))
  =>
  (bind ?question "共病以失眠为特征的精神障碍（如重性抑郁障碍）。(yes/no)?")
  (assert (check-psychotic-insomnia (yes-or-no-p ?question))))

(defrule INSOMNIA::check-insomnia-in-psychotic-disorder ""
  ?f <- (check-psychotic-insomnia yes)
  =>
  (retract ?f)
  (bind ?question "失眠可以用精神障碍充分解释。(yes/no)?")
  (assert (check-insomnia-in-psychotic-disorder (yes-or-no-p ?question))))

(defrule INSOMNIA::psychotic-disorder ""
  ?f <- (check-insomnia-in-psychotic-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "与失眠有关的精神障碍"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-somatic-disease ""
  (or (check-psychotic-insomnia no)
      (check-insomnia-in-psychotic-disorder no))
  =>
  (bind ?question "共病与失眠有关的一般躯体疾病（如背疼）。(yes/no)?")
  (assert (check-somatic-disease (yes-or-no-p ?question))))

(defrule INSOMNIA::check-insomnia-in-somatic-disease ""
  ?f <- (check-somatic-disease yes)
  =>
  (retract ?f)
  (bind ?question "失眠可以用一般躯体疾病充分解释。(yes/no)?")
  (assert (check-insomnia-in-somatic-disease (yes-or-no-p ?question))))

(defrule INSOMNIA::general-somatic-disease ""
  ?f <- (check-insomnia-in-somatic-disease yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "与失眠有关的一般躯体疾病"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-sleep-conditions ""
  (or (check-somatic-disease no)
      (check-insomnia-in-somatic-disease no))
  =>
  (bind ?question "缺乏充分的睡眠条件。(yes/no)?")
  (assert (check-sleep-conditions (yes-or-no-p ?question))))

(defrule INSOMNIA::non-sleep-disorder ""
  ?f <- (check-sleep-conditions yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "无睡眠障碍"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-sleep-disorder ""
  ?f <- (check-sleep-conditions no)
  =>
  (retract ?f)
  (bind ?question "每周至少出现3晚，持续至少3个月。(yes/no)?")
  (assert (check-sleep-disorder (yes-or-no-p ?question))))

(defrule INSOMNIA::sleep-disorder ""
  ?f <- (check-sleep-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "睡眠障碍"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::check-dysfunction ""
  ?f <- (check-sleep-disorder no)
  =>
  (retract ?f)
  (bind ?question "引起有临床意义的痛苦或损害并代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule INSOMNIA::check-adjustment-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源的反应出现。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule INSOMNIA::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::specific-unspecific-sleep-disorder ""
  ?f <- (check-adjustment-disorder no) 
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的失眠障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule INSOMNIA::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "对睡眠的“正常”需要（如“短睡眠者”）。"))
  (extract-ordered-facts)
  (halt))


;;;*******************************
;;;* cc20: HYPERSOMNOLENCE RULES *
;;;*******************************
(defrule HYPERSOMNOLENCE::subsystem-banner ""
  (chief-complaint "嗜睡")
  =>
  (println "用于嗜睡的决策树" crlf)
  (assert (check substance-use)))

(defrule HYPERSOMNOLENCE::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-substance-use-impairment ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡是主要临床表现且严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-impairment (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::substance-ues-sleep-disorder-hypersomnolence ""
  ?f <- (check-substance-use-impairment yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的睡眠障碍，日间困倦型。"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use-impairment no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断。"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-narcolepsy-symptoms ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "反复发生不可抗拒的睡眠需要伴猝倒发作，下丘脑分泌素缺乏，典型的夜间多导睡眠图发现或典型的多次睡眠潜伏期测试发现。(yes/no)?")
  (assert (check-narcolepsy-symptoms (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-in-narcolepsy ""
  ?f <- (check-narcolepsy-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡仅出现在发作性睡病期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-hypersomnolence-in-narcolepsy (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::narcolepsy ""
  ?f <- (check-hypersomnolence-in-narcolepsy yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "发作性睡病"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-polysomnographic-evidence ""
  (or (check-narcolepsy-symptoms no)
      (check-hypersomnolence-in-narcolepsy no))
  =>
  (bind ?question "伴有以下多导睡眠图的证据，即每小时睡眠至少有5次阻塞性呼吸暂停或低通气，每小时睡眠至少有5次中枢性呼吸暂停，或与二氧化碳水平升高有关的呼吸次数减少。(yes/no)?")
  (assert (check-polysomnographic-evidence (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-in-sleep-breathing ""
  ?f <- (check-polysomnographic-evidence yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡仅出现在与呼吸相关的睡眠障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-hypersomnolence-in-sleep-breathing (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::sleep-breathing-disorder ""
  ?f <- (check-hypersomnolence-in-sleep-breathing yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "与呼吸相关的睡眠障碍（即阻塞性睡眠呼吸暂停低通气、中枢性睡眠呼吸暂停、睡眠相关的通气不足）"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-sleep-walking-terrors ""
  (or (check-polysomnographic-evidence no)
      (check-hypersomnolence-in-sleep-breathing no))
  =>
  (bind ?question "日间疲乏是由于睡行或睡惊症状所致。(yes/no)?")
  (assert (check-sleep-walking-terrors (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-in-NREM ""
  ?f <- (check-sleep-walking-terrors yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡仅出现在非快速眼动睡眠唤醒障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-hypersomnolence-in-NREM (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::non-REM-sleep-arousal-disorder ""
  ?f <- (check-hypersomnolence-in-NREM yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "非快速眼动睡眠唤醒障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-dreams ""
  (or (check-sleep-walking-terrors no)
      (check-hypersomnolence-in-NREM no))
  =>
  (bind ?question "日间疲乏是由于反复发生延长的、极端令人烦躁和记忆完好的梦境。(yes/no)?")
  (assert (check-dreams (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-in-nightmare ""
  ?f <- (check-dreams yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡仅出现在梦魇障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-hypersomnolence-in-nightmare (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::nightmare-disorder ""
  ?f <- (check-hypersomnolence-in-nightmare yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "梦魇障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-REM ""
  (or (check-dreams no)
      (check-hypersomnolence-in-nightmare no))
  =>
  (bind ?question "日间疲乏是由于睡眠期间反复从快速眼动睡眠中觉醒，伴有发声或复杂的运动行为。(yes/no)?")
  (assert (check-REM (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-in-REM ""
  ?f <- (check-REM yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡仅出现在快速眼动睡眠行为障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-hypersomnolence-in-REM (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::REM-sleep-behavior-disorder ""
  ?f <- (check-hypersomnolence-in-REM yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "快速眼动睡眠行为障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-restless-legs-syndrome ""
  (or (check-REM no)
      (check-hypersomnolence-in-REM no))
  =>
  (bind ?question "日间疲乏是由于存在移动双腿的冲动，对不愉快的感觉做出反应。(yes/no)?")
  (assert (check-restless-legs-syndrome (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-in-restless-legs-syndrome ""
  ?f <- (check-restless-legs-syndrome yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡仅出现在不安腿综合征期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-hypersomnolence-in-restless-legs-syndrome (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::restless-legs-syndrome ""
  ?f <- (check-hypersomnolence-in-restless-legs-syndrome yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "不安腿综合征"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-circadian-rhythm ""
  (or (check-restless-legs-syndrome no)
      (check-hypersomnolence-in-restless-legs-syndrome no))
  =>
  (bind ?question "日间疲乏与个体的时间表和自然的睡眠觉醒模式之间不匹配相关。(yes/no)?")
  (assert (check-circadian-rhythm (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-in-circadian-rhythm ""
  ?f <- (check-circadian-rhythm yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡仅出现在昼夜节律睡眠-觉醒障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-hypersomnolence-in-circadian-rhythm (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::circadian-rhythm-sleep-wake-disorder ""
  ?f <- (check-hypersomnolence-in-circadian-rhythm yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "昼夜节律睡眠-觉醒障碍（即延迟睡眠时相型，提前睡眠时相型，不规律的睡眠觉醒型，非24小时睡眠-觉醒型，倒班工作型，未特定型）。"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-insomnia-complaints ""
  (or (check-circadian-rhythm no)
      (check-hypersomnolence-in-circadian-rhythm no))
  =>
  (bind ?question "最突出的主诉是对睡眠时长或质量不满意，伴难以入睡或维持睡眠或早醒。(yes/no)?")
  (assert (check-insomnia-complaints (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-insomnia-disorder ""
  ?f <- (check-insomnia-complaints yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡仅出现在失眠障碍期间，并可用这一诊断更好地解释。(yes/no)?")
  (assert (check-insomnia-disorder (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::insomnia-disorder ""
  ?f <- (check-insomnia-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "失眠障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-psychotic-hypersomnolence ""
  (or (check-insomnia-complaints no)
      (check-insomnia-disorder no))
  =>
  (bind ?question "共病以日间疲乏为特征的精神障碍（如重性抑郁障碍）。(yes/no)?")
  (assert (check-psychotic-hypersomnolence (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-in-psychotic-disorder ""
  ?f <- (check-psychotic-hypersomnolence yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡可以用精神障碍充分解释。(yes/no)?")
  (assert (check-hypersomnolence-in-psychotic-disorder (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::psychotic-disorder ""
  ?f <- (check-hypersomnolence-in-psychotic-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "与嗜睡有关的精神障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-somatic-disease ""
  (or (check-psychotic-hypersomnolence no)
      (check-hypersomnolence-in-psychotic-disorder no))
  =>
  (bind ?question "共病以日间疲乏为特征的一般躯体疾病（如单核细胞增多症）。(yes/no)?")
  (assert (check-somatic-disease (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-in-somatic-disease ""
  ?f <- (check-somatic-disease yes)
  =>
  (retract ?f)
  (bind ?question "嗜睡可以用一般躯体疾病充分解释。(yes/no)?")
  (assert (check-hypersomnolence-in-somatic-disease (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::general-somatic-disease ""
  ?f <- (check-hypersomnolence-in-somatic-disease yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "与嗜睡有关的一般躯体疾病"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-sleep-deprivation ""
  (or (check-somatic-disease no)
      (check-hypersomnolence-in-somatic-disease no))
  =>
  (bind ?question "由于“自愿的”睡眠剥夺。(yes/no)?")
  (assert (check-sleep-deprivation (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::non-sleep-disorder ""
  ?f <- (check-sleep-deprivation yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "无睡眠障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-hypersomnolence-disorder ""
  ?f <- (check-sleep-deprivation no)
  =>
  (retract ?f)
  (bind ?question "每周至少出现3晚，持续至少3个月。(yes/no)?")
  (assert (check-hypersomnolence-disorder (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::hypersomnolence-disorder ""
  ?f <- (check-hypersomnolence-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "嗜睡障碍"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::check-dysfunction ""
  ?f <- (check-hypersomnolence-disorder no)
  =>
  (retract ?f)
  (bind ?question "引起有临床意义的痛苦或损害并代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule HYPERSOMNOLENCE::specific-unspecific-hypersomnolence-disorder ""
  ?f <- (check-dysfunction yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的嗜睡障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule HYPERSOMNOLENCE::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "对睡眠的“正常”需要（如“长睡眠者”）。"))
  (extract-ordered-facts)
  (halt))


;;;*****************************************
;;;* cc21: SEXUAL-DYSFUNCTION-FEMALE RULES *
;;;*****************************************
(defrule SEXUAL-DYSFUNCTION-FEMALE::subsystem-banner ""
  (chief-complaint "女性性功能失调")
  =>
  (println "用于女性性功能失调的决策树" crlf)
  (assert (check stimulation)))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-stimulation ""
  ?f <- (check stimulation)
  =>
  (retract ?f)
  (bind ?question "完全可以解释为缺乏充分的刺激。(yes/no)?")
  (assert (check-stimulation (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::non-sexual-dysfunction ""
  ?f <- (check-stimulation yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "不是性功能失调。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-somatic-disease ""
  ?f <- (check-stimulation no)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病（如骨盆神经受损）的生理效应所致。(yes/no)?")
  (assert (check-somatic-disease (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::general-somatic-disease ""
  ?f <- (check-somatic-disease yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由一般躯体疾病引起的性功能失调。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-substance-use ""
  ?f <- (check-somatic-disease no)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-substance-use-impairment ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "性功能失调症状是主要临床表现并严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-impairment (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::substance-use-impairment ""
  ?f <- (check-substance-use-impairment yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的性功能失调。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use-impairment no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-psychotic-disorder ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "可以用其他精神障碍（如重性抑郁障碍）来更好地解释。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::psychotic-disorder ""
  ?f <- (check-psychotic-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "精神障碍的诊断（不必额外诊断为性功能失调）。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-relation-distress ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "可以更好地解释为严重关系困扰的后果。(yes/no)?")
  (assert (check-relation-distress (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::relation-distress ""
  ?f <- (check-relation-distress yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "关系问题"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-sexual-interest-arousal ""
  ?f <- (check-relation-distress no)
  =>
  (retract ?f)
  (bind ?question "由性兴趣或唤起的程度显著降低（即兴趣减退、情色想法减少、发起性活动的次数减少，在性活动中兴奋度或愉悦感降低，在性活动中生殖器的感觉减退），持续至少6个月，并引起有临床意义的痛苦。(yes/no)?")
  (assert (check-sexual-interest-arousal (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-desire-differences ""
  ?f <- (check-sexual-interest-arousal yes)
  =>
  (retract ?f)
  (bind ?question "发生在“欲望差异”的背景下，女性对性活动的兴趣比其性伴侣要低。(yes/no)?")
  (assert (check-desire-differences (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::female-sexual-interest-arousal-disorder ""
  ?f <- (check-desire-differences no) 
  =>
  (retract ?f)  
  (assert (diagnosis "女性性兴趣/唤起障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-female-orgasmic-disorder ""
  (or (check-sexual-interest-arousal no)
      (check-desire-differences yes))
  =>
  (bind ?question "性高潮的显著延迟、极少或达不到性高潮或是性高潮感觉的强度降低，持续至少6个月，并引起有临床意义的痛苦。(yes/no)?")
  (assert (check-female-orgasmic-disorder (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::female-orgasmic-disorder ""
  ?f <- (check-female-orgasmic-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "女性性高潮障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-genito-pelvic-pain-penetration-disorder ""
  ?f <- (check-female-orgasmic-disorder no)
  =>
  (retract ?f)
  (bind ?question "难以进行阴道性交或插入，或在性交时有外阴阴道或盆腔疼痛，对外阴阴道的疼痛感到害怕或焦虑，或在尝试插入时，盆底肌肉紧张或僵硬，持续至少6个月，并引起有临床意义的痛苦。(yes/no)?")
  (assert (check-genito-pelvic-pain-penetration-disorder (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::genito-pelvic-pain-penetration-disorder ""
  ?f <- (check-genito-pelvic-pain-penetration-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "女性生殖器-盆腔痛/插入障碍性性高潮障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-dysfunction ""
  ?f <- (check-genito-pelvic-pain-penetration-disorder no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的性功能失调代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::check-adjustment-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源的反应出现。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-FEMALE::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::specific-unspecific-sexual-dysfunction ""
  ?f <- (check-adjustment-disorder no) 
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的性功能失调。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-FEMALE::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "性功能的“正常”变异。"))
  (extract-ordered-facts)
  (halt))


;;;***************************************
;;;* cc22: SEXUAL-DYSFUNCTION-MALE RULES *
;;;***************************************
(defrule SEXUAL-DYSFUNCTION-MALE::subsystem-banner ""
  (chief-complaint "男性性功能失调")
  =>
  (println "用于男性性功能失调的决策树" crlf)
  (assert (check stimulation)))

(defrule SEXUAL-DYSFUNCTION-MALE::check-stimulation ""
  ?f <- (check stimulation)
  =>
  (retract ?f)
  (bind ?question "完全可以解释为缺乏充分的刺激。(yes/no)?")
  (assert (check-stimulation (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::non-sexual-dysfunction ""
  ?f <- (check-stimulation yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "不是性功能失调。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::check-somatic-disease ""
  ?f <- (check-stimulation no)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病（如血管性疾病）的生理效应所致。(yes/no)?")
  (assert (check-somatic-disease (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE:general-somatic-disease ""
  ?f <- (check-somatic-disease yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由一般躯体疾病引起的性功能失调。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::check-substance-use ""
  ?f <- (check-somatic-disease no)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::check-substance-use-impairment ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "性功能失调症状是主要临床表现并严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-impairment (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::substance-use-impairment ""
  ?f <- (check-substance-use-impairment yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的性功能失调。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use-impairment no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE:check-psychotic-disorder ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "可以用其他精神障碍（如重性抑郁障碍）来更好地解释。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::psychotic-disorder ""
  ?f <- (check-psychotic-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "精神障碍的诊断（不必额外诊断为性功能失调）。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::check-relation-distress ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "可以更好地解释为严重关系困扰的后果。(yes/no)?")
  (assert (check-relation-distress (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::relation-distress ""
  ?f <- (check-relation-distress yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "关系问题"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::check-male-hypoactive-sexual-desire-disorder ""
  ?f <- (check-relation-distress no)
  =>
  (retract ?f)
  (bind ?question "缺乏对性或情色的想法、幻想和对性活动的欲望，持续至少6个月并引起有临床意义的痛苦。(yes/no)?")
  (assert (check-male-hypoactive-sexual-desire-disorder (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::check-desire-differences ""
  ?f <- (check-male-hypoactive-sexual-desire-disorder yes)
  =>
  (retract ?f)
  (bind ?question "发生在“欲望差异”的背景下，男性对性活动的兴趣比其性伴侣要低。(yes/no)?")
  (assert (check-desire-differences (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::male-hypoactive-sexual-desire-disorder ""
  ?f <- (check-desire-differences no) 
  =>
  (retract ?f)  
  (assert (diagnosis "男性性欲低下障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::check-erectile-disorder ""
  (or (check-male-hypoactive-sexual-desire-disorder no)
      (check-desire-differences yes))
  =>
  (bind ?question "性活动时明显难以达到或维持勃起，持续至少6个月并引起有临床意义的痛苦。(yes/no)?")
  (assert (check-erectile-disorder (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::erectile-disorder ""
  ?f <- (check-erectile-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "勃起障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::check-premature-ejaculation ""
  ?f <- (check-erectile-disorder no)
  =>
  (retract ?f)
  (bind ?question "在与伴侣的性活动中，在插入阴道后1分钟内，并在个体的意愿之前出现射精，持续至少6个月并引起有临床意义的痛苦。(yes/no)?")
  (assert (check-premature-ejaculation (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::premature-ejaculation ""
  ?f <- (check-premature-ejaculation yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "早泄"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::check-delayed-ejaculation ""
  ?f <- (check-premature-ejaculation no)
  =>
  (retract ?f)
  (bind ?question "显著的射精延迟或是极少或没有射精，持续至少6个月并引起有临床意义的痛苦。(yes/no)?")
  (assert (check-delayed-ejaculation (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::delayed-ejaculation ""
  ?f <- (check-delayed-ejaculation yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "延迟射精"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::check-dysfunction ""
  ?f <- (check-delayed-ejaculation no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的性功能失调代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::check-adjustment-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源的反应出现。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule SEXUAL-DYSFUNCTION-MALE::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::specific-unspecific-sexual-dysfunction ""
  ?f <- (check-adjustment-disorder no) 
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的性功能失调。"))
  (extract-ordered-facts)
  (halt))

(defrule SEXUAL-DYSFUNCTION-MALE::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "性功能的“正常”变异。"))
  (extract-ordered-facts)
  (halt))


;;;***********************************
;;;* cc23: AGGRESSIVE-BEHAVIOR RULES *
;;;***********************************
(defrule AGGRESSIVE-BEHAVIOR::subsystem-banner ""
  (chief-complaint "攻击行为")
  =>
  (println "用于攻击行为的决策树" crlf)
  (assert (check substance-use)))

(defrule AGGRESSIVE-BEHAVIOR::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::check-substance-use-delirium ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-substance-use-delirium (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::substance-use-delirium ""
  ?f <- (check-substance-use-delirium yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-substance-use-neurocognitive-disorder ""
  ?f <- (check-substance-use-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-substance-use-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::substance-use-neurocognitive-disorder ""
  ?f <- (check-substance-use-neurocognitive-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::substance-use-intoxication-withdrawal ""
  ?f <- (check-substance-use-neurocognitive-disorder no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::check-medical-conditions-delirium ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-medical-conditions-delirium (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::medical-conditions-delirium ""
  ?f <- (check-medical-conditions-delirium yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-medical-conditions-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-medical-conditions-personality-change ""
  ?f <- (check-medical-conditions-neurocognitive-disorder no)
  =>
  (retract ?f)
  (bind ?question "代表了与先前人格模式相比发生的改变。(yes/no)?")
  (assert (check-medical-conditions-personality-change (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::medical-conditions-personality-change ""
  ?f <- (check-medical-conditions-personality-change yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的人格改变，攻击型。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::medical-conditions-specific-psychotic-disorder ""
  ?f <- (check-medical-conditions-personality-change no) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的其他特定的精神障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-psychotic-disorder ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "发生在妄想或幻觉的背景下。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::psychotic-disorder ""
  ?f <- (check-psychotic-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "精神病性障碍，如精神分裂症。参见用于鉴别诊断的妄想树形图或幻觉树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-catatonic-symptoms ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "激越与至少两个典型的紧张症症状有关（如僵直、蜡样屈曲、违拗、作态、刻板运动、模仿言语）。(yes/no)?")
  (assert (check-catatonic-symptoms (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::catatonia ""
  ?f <- (check-catatonic-symptoms yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "紧张症。参见用于鉴别诊断的紧张症症状树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-bipolar-disorder ""
  ?f <- (check-catatonic-symptoms no)
  =>
  (retract ?f)
  (bind ?question "发生在心境高涨的背景下。(yes/no)?")
  (assert (check-bipolar-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::bipolar-disorder ""
  ?f <- (check-bipolar-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "在双相I型障碍或分裂情感性障碍中的躁狂发作。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-violating-social-norms ""
  ?f <- (check-bipolar-disorder no)
  =>
  (retract ?f)
  (bind ?question "作为一种侵犯他人基本权利并违反与年龄相符的社会规范的模式的一部分。(yes/no)?")
  (assert (check-violating-social-norms (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::check-age-18 ""
  ?f <- (check-violating-social-norms yes)
  =>
  (retract ?f)
  (bind ?question "年龄超过18岁。(yes/no)?")
  (assert (check-age-18 (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::antisocial-personality-disorder ""
  ?f <- (check-age-18 yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "反社会型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::conduct-disorder ""
  ?f <- (check-age-18 no) 
  =>
  (retract ?f)  
  (assert (diagnosis "品行障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-borderline-personality-disorder ""
  ?f <- (check-violating-social-norms no)
  =>
  (retract ?f)
  (bind ?question "作为一种以发怒、心境失调和身份紊乱为特征的持续人格紊乱表现的一部分。(yes/no)?")
  (assert (check-borderline-personality-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::borderline-personality-disorder ""
  ?f <- (check-borderline-personality-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "边缘型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-disruptive-mood-dysregulation-disorder ""
  ?f <- (check-borderline-personality-disorder no)
  =>
  (retract ?f)
  (bind ?question "存在严重的脾气爆发，与所处情境完全不成比例，伴有爆发期间的持续性愤怒和易激惹。(yes/no)?")
  (assert (check-disruptive-mood-dysregulation-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::disruptive-mood-dysregulation-disorder ""
  ?f <- (check-disruptive-mood-dysregulation-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "破坏性心境失调障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-oppositional-defiant-disorder ""
  ?f <- (check-disruptive-mood-dysregulation-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生与一种争辩、对抗和报复的模式有关。(yes/no)?")
  (assert (check-oppositional-defiant-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::oppositional-defiant-disorder ""
  ?f <- (check-oppositional-defiant-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "对立违抗障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-ADHD ""
  ?f <- (check-oppositional-defiant-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生与持续的多动、冲动和注意力不集中症状有关。(yes/no)?")
  (assert (check-ADHD (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::check-ADHD-impairment ""
  ?f <- (check-ADHD yes)
  =>
  (retract ?f)
  (bind ?question "发生在至少两种不同情境中并引起有临床意义的损害，并且在12岁之前就存在若干症状。(yes/no)?")
  (assert (check-ADHD-impairment (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::ADHD ""
  ?f <- (check-ADHD-impairment yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "注意缺陷/多动障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-separation-anxiety-disorder ""
  (or (check-ADHD no)
      (check-ADHD-impairment no))
  =>
  (bind ?question "作为与主要依恋对象分离的反应出现。(yes/no)?")
  (assert (check-separation-anxiety-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::separation-anxiety-disorder ""
  ?f <- (check-separation-anxiety-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "分离焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-autism-spectrum-disorder ""
  ?f <- (check-separation-anxiety-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生与社交交流和社交互动上的持续缺陷有关，伴有受限、反复的行为、兴趣或活动模式。(yes/no)?")
  (assert (check-autism-spectrum-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::autism-spectrum-disorder ""
  ?f <- (check-autism-spectrum-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "自闭症谱系障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-intellectual-disability ""
  ?f <- (check-autism-spectrum-disorder no)
  =>
  (retract ?f)
  (bind ?question "发生与智力功能的缺陷有关，伴有适应功能的缺陷，并起病于发育期。(yes/no)?")
  (assert (check-intellectual-disability (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::intellectual-disability ""
  ?f <- (check-intellectual-disability yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "智力障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-intermittent-explosive-disorder ""
  ?f <- (check-intellectual-disability no)
  =>
  (retract ?f)
  (bind ?question "发生在攻击行为的发作完全与所处情境不成比例的背景下。(yes/no)?")
  (assert (check-intermittent-explosive-disorder (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::intermittent-explosive-disorder ""
  ?f <- (check-intermittent-explosive-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "间歇性暴怒障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-psychosocial-stressors ""
  ?f <- (check-intermittent-explosive-disorder no)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源的症状反应出现。(yes/no)?")
  (assert (check-psychosocial-stressors (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::check-traumatic-stressors ""
  ?f <- (check-psychosocial-stressors yes)
  =>
  (retract ?f)
  (bind ?question "应激源具有极端的创伤性质（如危及生命的情境）并有对创伤的反复再体验。(yes/no)?")
  (assert (check-traumatic-stressors (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::PTSD-acute-stress-disorder ""
  ?f <- (check-traumatic-stressors yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "创伤后应激障碍或急性应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::adjustment-disorder ""
  ?f <- (check-traumatic-stressors no) 
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::check-dysfunction ""
  ?f <- (check-psychosocial-stressors no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的攻击行为代表了个体在心理上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule AGGRESSIVE-BEHAVIOR::unspecific-disruptive-impulse-control-conduct-disorder ""
  ?f <- (check-dysfunction yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "未特定的破坏性、冲动控制及品行障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule AGGRESSIVE-BEHAVIOR::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "非精神疾病的攻击行为（如反社会行为）。"))
  (extract-ordered-facts)
  (halt))


;;;******************************************************
;;;* cc24: IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS RULES *
;;;******************************************************
(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::subsystem-banner ""
  (chief-complaint "冲动性或冲动控制问题")
  =>
  (println "用于冲动性或冲动控制问题的决策树" crlf)
  (assert (check substance-use)))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-substance-use-delirium ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-substance-use-delirium (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::substance-use-delirium ""
  ?f <- (check-substance-use-delirium yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::substance-use-intoxication-withdrawal ""
  ?f <- (check-substance-use-delirium no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-medical-conditions-delirium ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-medical-conditions-delirium (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::medical-conditions-delirium ""
  ?f <- (check-medical-conditions-delirium yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-delirium no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-medical-conditions-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-medical-conditions-neurocognitive-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍，伴行为紊乱。"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-medical-conditions-personality-change ""
  ?f <- (check-medical-conditions-neurocognitive-disorder no)
  =>
  (retract ?f)
  (bind ?question "代表了与先前人格模式相比发生的改变。(yes/no)?")
  (assert (check-medical-conditions-personality-change (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::medical-conditions-personality-change ""
  ?f <- (check-medical-conditions-personality-change yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的人格改变。"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::medical-conditions-specific-unspecific-psychotic-disorder ""
  ?f <- (check-medical-conditions-personality-change no) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的其他特定的或未特定的精神障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-mania-seizure ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "发生在心境高涨、膨胀或易激惹伴有活动或精力增加的背景下。(yes/no)?")
  (assert (check-mania-seizure (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::mania-seizure ""
  ?f <- (check-mania-seizure yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "在双相I型障碍或分裂情感性障碍中的躁狂发作。"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-major-depressive-episode ""
  ?f <- (check-mania-seizure no)
  =>
  (retract ?f)
  (bind ?question "发生在发作抑郁心境或者兴趣或愉悦感减退并伴有特征性抑郁症状（如自杀行为）的背景下。(yes/no)?")
  (assert (check-major-depressive-episode (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::major-depressive-episode ""
  ?f <- (check-major-depressive-episode yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "在重性抑郁障碍、双相I型障碍或双相II型障碍或分裂情感性障碍中的重性抑郁发作。"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-ADHD ""
  ?f <- (check-major-depressive-episode no)
  =>
  (retract ?f)
  (bind ?question "与注意力不集中和多动症状有关，起病于12岁之前并有干扰功能的明确证据。(yes/no)?")
  (assert (check-ADHD (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::ADHD ""
  ?f <- (check-ADHD yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "注意缺陷/多动障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-violating-social-norms ""
  ?f <- (check-ADHD no)
  =>
  (retract ?f)
  (bind ?question "作为一种侵犯他人基本权利并违反与年龄相符的社会规范的模式的一部分。(yes/no)?")
  (assert (check-violating-social-norms (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-age-18 ""
  ?f <- (check-violating-social-norms yes)
  =>
  (retract ?f)
  (bind ?question "年龄超过18岁。(yes/no)?")
  (assert (check-age-18 (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::antisocial-personality-disorder ""
  ?f <- (check-age-18 yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "反社会型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::conduct-disorder ""
  ?f <- (check-age-18 no) 
  =>
  (retract ?f)  
  (assert (diagnosis "品行障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-borderline-personality-disorder ""
  ?f <- (check-violating-social-norms no)
  =>
  (retract ?f)
  (bind ?question "一种起病于成年早期的冲动模式的一部分。(yes/no)?")
  (assert (check-borderline-personality-disorder (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::borderline-personality-disorder ""
  ?f <- (check-borderline-personality-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "边缘型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-substance-use-control-ability ""
  ?f <- (check-borderline-personality-disorder no)
  =>
  (retract ?f)
  (bind ?question "控制物质使用的能力受损。(yes/no)?")
  (assert (check-substance-use-control-ability (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::substance-use-disorder ""
  ?f <- (check-substance-use-control-ability yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质使用障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-gambling-disorder ""
  ?f <- (check-substance-use-control-ability no)
  =>
  (retract ?f)
  (bind ?question "控制赌博的能力受损。(yes/no)?")
  (assert (check-gambling-disorder (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::gambling-disorder ""
  ?f <- (check-gambling-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "赌博障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-binge-eating-disorder ""
  ?f <- (check-gambling-disorder no)
  =>
  (retract ?f)
  (bind ?question "无法克制暴食的冲动。(yes/no)?")
  (assert (check-binge-eating-disorder (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::binge-eating-disorder ""
  ?f <- (check-binge-eating-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "神经性贪食，暴食障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-pyromania ""
  ?f <- (check-binge-eating-disorder no)
  =>
  (retract ?f)
  (bind ?question "发作性的无法克制放火的冲动。(yes/no)?")
  (assert (check-pyromania (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::pyromania ""
  ?f <- (check-pyromania yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "纵火狂"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-kleptomania ""
  ?f <- (check-pyromania no)
  =>
  (retract ?f)
  (bind ?question "发作性的无法克制偷窃无用物品的冲动。(yes/no)?")
  (assert (check-kleptomania (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::kleptomania ""
  ?f <- (check-kleptomania yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "偷窃狂"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-hair-pulling-disorder ""
  ?f <- (check-kleptomania no)
  =>
  (retract ?f)
  (bind ?question "发作性的无法克制拔除自身毛发的冲动。(yes/no)?")
  (assert (check-hair-pulling-disorder (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::hair-pulling-disorder ""
  ?f <- (check-hair-pulling-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "拔毛癖"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-skin-picking-disorder ""
  ?f <- (check-hair-pulling-disorder no)
  =>
  (retract ?f)
  (bind ?question "发作性的无法克制搔抓自身皮肤的冲动。(yes/no)?")
  (assert (check-skin-picking-disorder (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::skin-picking-disorder ""
  ?f <- (check-skin-picking-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "皮肤搔抓障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-intermittent-explosive-disorder ""
  ?f <- (check-skin-picking-disorder no)
  =>
  (retract ?f)
  (bind ?question "发作性的无法克制攻击冲动。(yes/no)?")
  (assert (check-intermittent-explosive-disorder (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::intermittent-explosive-disorder ""
  ?f <- (check-intermittent-explosive-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "间歇性暴怒障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-traumatic-stressors ""
  ?f <- (check-intermittent-explosive-disorder no)
  =>
  (retract ?f)
  (bind ?question "冲动性产生于对创伤性应激源的反应，伴有侵入症状、回避症状和认知及心境的负性改变。(yes/no)?")
  (assert (check-traumatic-stressors (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-course ""
  ?f <- (check-traumatic-stressors yes)
  =>
  (retract ?f)
  (bind ?question "病程超过1个月。(yes/no)?")
  (assert (check-course (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::PTSD ""
  ?f <- (check-course yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "创伤后应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::acute-stress-disorder ""
  ?f <- (check-course no) 
  =>
  (retract ?f)  
  (assert (diagnosis "急性应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-dysfunction ""
  ?f <- (check-traumatic-stressors no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的冲动性代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::check-adjustment-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "对心理社会应激源适应不良的反应。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::specific-unspecific-disruptive-impulse-control-conduct-disorder ""
  ?f <- (check-adjustment-disorder no) 
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的破坏性、冲动控制及品行障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule IMPULSIVITY-IMPULSIVE-CONTROL-PROBLEMS::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”冲动性"))
  (extract-ordered-facts)
  (halt))


;;;*******************************************
;;;* cc25: SELF-INJURY-SELF-MUTILATION RULES *
;;;*******************************************
(defrule SELF-INJURY-SELF-MUTILATION::subsystem-banner ""
  (chief-complaint "自伤或自残")
  =>
  (println "用于自伤或自残的决策树" crlf)
  (assert (check suicide-attempt)))

(defrule SELF-INJURY-SELF-MUTILATION::check-suicide-attempt ""
  ?f <- (check suicide-attempt)
  =>
  (retract ?f)
  (bind ?question "失败的自杀企图的一部分。(yes/no)?")
  (assert (check-suicide-attempt (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::suicide-attempt ""
  ?f <- (check-suicide-attempt yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "参见用于鉴别诊断的自杀观念或行为树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-culture-behavior ""
  ?f <- (check-suicide-attempt no)
  =>
  (retract ?f)
  (bind ?question "文化上认可的行为（如穿环）。(yes/no)?")
  (assert (check-culture-behavior (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::culture-behavior ""
  ?f <- (check-culture-behavior yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”自残"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-substance-use ""
  ?f <- (check-culture-behavior no)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::check-substance-use-impairment ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "认知损害（如意识错乱）或精神病性症状的直接后果。(yes/no)?")
  (assert (check-substance-use-impairment (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::substance-use-disorder ""
  ?f <- (check-substance-use-impairment yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的重度神经认知障碍，物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄，物质/药物所致的精神病性障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::substance-intoxication-withdrawal ""
  ?f <- (check-substance-use-impairment no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::check-medical-conditions-impairment ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "认知损害（如意识错乱）或精神病性症状的直接后果。(yes/no)?")
  (assert (check-medical-conditions-impairment (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::medical-conditions-psychotic-disorder ""
  ?f <- (check-medical-conditions-impairment yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的神经认知障碍、谵妄或精神病性障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::medical-conditions-personality-change ""
  ?f <- (check-medical-conditions-impairment no) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的人格改。"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-borderline-personality-disorder ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "自伤的动机是降低烦躁、宣泄愤怒的感受，或降低麻木或“死气沉沉”的感受，与一种冲动及身份紊乱的模式有关。(yes/no)?")
  (assert (check-borderline-personality-disorder (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::borderline-personality-disorder ""
  ?f <- (check-borderline-personality-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "边缘型人格障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-schizophrenia ""
  ?f <- (check-borderline-personality-disorder no)
  =>
  (retract ?f)
  (bind ?question "作为对妄想或命令性幻觉的反应。(yes/no)?")
  (assert (check-schizophrenia (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::schizophrenia ""
  ?f <- (check-schizophrenia yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "精神病性障碍，如精神分裂症。参见用于鉴别诊断的妄想树形图或幻觉树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-OCD ""
  ?f <- (check-schizophrenia no)
  =>
  (retract ?f)
  (bind ?question "强迫行为的后果（如频繁地剧烈洗手）。(yes/no)?")
  (assert (check-OCD (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::OCD ""
  ?f <- (check-OCD yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "强迫症"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-hair-pulling-disorder ""
  ?f <- (check-OCD no)
  =>
  (retract ?f)
  (bind ?question "与反复拔除毛发有关，导致脱发。(yes/no)?")
  (assert (check-hair-pulling-disorder (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::hair-pulling-disorder ""
  ?f <- (check-hair-pulling-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "拔毛癖"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-skin-picking-disorder ""
  ?f <- (check-hair-pulling-disorder no)
  =>
  (retract ?f)
  (bind ?question "与反复搔抓皮肤有关，导致皮肤破损。(yes/no)?")
  (assert (check-skin-picking-disorder (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::skin-picking-disorder ""
  ?f <- (check-skin-picking-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "皮肤搔抓障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-sexual-masochism ""
  ?f <- (check-skin-picking-disorder no)
  =>
  (retract ?f)
  (bind ?question "动机是获得性愉悦感。(yes/no)?")
  (assert (check-sexual-masochism (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::sexual-masochism-disorder ""
  ?f <- (check-sexual-masochism yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "性受虐障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-stereotypical-movement-disorder ""
  ?f <- (check-sexual-masochism no)
  =>
  (retract ?f)
  (bind ?question "刻板运动的后果（如撞头）。(yes/no)?")
  (assert (check-stereotypical-movement-disorder (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::stereotypical-movement-disorder ""
  ?f <- (check-stereotypical-movement-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "刻板运动障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-fake ""
  ?f <- (check-stereotypical-movement-disorder no)
  =>
  (retract ?f)
  (bind ?question "伪造的自伤。(yes/no)?")
  (assert (check-fake (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::check-facticious-disorder ""
  ?f <- (check-fake yes)
  =>
  (retract ?f)
  (bind ?question "在没有明显的外部奖赏时，欺骗行为也是显而易见的。(yes/no)?")
  (assert (check-facticious-disorder (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::facticious-disorder ""
  ?f <- (check-facticious-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "做作性障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::malinger ""
  ?f <- (check-facticious-disorder no) 
  =>
  (retract ?f)  
  (assert (diagnosis "诈病"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::check-dysfunction ""
  ?f <- (check-fake no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的自伤行为代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::check-adjustment-disorder ""
  ?f <- (check-dysfunction yes)
  =>
  (retract ?f)
  (bind ?question "作为对心理社会应激源适应不良的反应。(yes/no)?")
  (assert (check-adjustment-disorder (yes-or-no-p ?question))))

(defrule SELF-INJURY-SELF-MUTILATION::adjustment-disorder ""
  ?f <- (check-adjustment-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "适应障碍"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::non-suicidal-self-injury ""
  ?f <- (check-adjustment-disorder no) 
  =>
  (retract ?f)  
  (assert (diagnosis "第三部分：非自杀性自我伤害。"))
  (extract-ordered-facts)
  (halt))

(defrule SELF-INJURY-SELF-MUTILATION::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”自伤行为"))
  (extract-ordered-facts)
  (halt))


;;;**************************************
;;;* cc26: EXCESSIVE-SUBTANCE-USE RULES *
;;;**************************************
(defrule EXCESSIVE-SUBTANCE-USE::subsystem-banner ""
  (chief-complaint "过度物质使用")
  =>
  (println "用于过度物质使用的决策树" crlf)
  (assert (check problematic-substance-use-patterns)))

(defrule EXCESSIVE-SUBTANCE-USE::check-problematic-substance-use-patterns ""
  ?f <- (check problematic-substance-use-patterns)
  =>
  (retract ?f)
  (bind ?question "有问题的物质使用模式导致有临床意义的损害或痛苦（如摄入的物质经常比预期的量更大，由于物质使用而放弃社交、职业或娱乐活动，在对身体有害的情况下仍反复使用）。(yes/no)?")
  (assert (check-problematic-substance-use-patterns (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-impairment ""
  ?f <- (check-problematic-substance-use-patterns yes)
  =>
  (retract ?f)
  (bind ?question "存在由于物质对中枢神经系统的直接生理效应导致的精神症状。(yes/no)?")
  (assert (check-substance-use-impairment (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-disorder ""
  ?f <- (check-substance-use-impairment yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质使用障碍"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-psychotic-symptoms ""
  (or (check-problematic-substance-use-patterns no)
      (check-substance-use-impairment no))
  =>
  (bind ?question "存在由于物质对中枢神经系统的直接生理效应导致的有临床意义的精神症状。(yes/no)?")
  (assert (check-substance-use-psychotic-symptoms (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::non-substance-use-disorder ""
  ?f <- (check-substance-use-psychotic-symptoms no) 
  =>
  (retract ?f)  
  (assert (diagnosis "不是物质所致的障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-fluctuating-course ""
  ?f <- (check-substance-use-psychotic-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "注意和意识紊乱，以波动性病程为特征。(yes/no)?")
  (assert (check-fluctuating-course (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::check-etiological-evidence ""
  ?f <- (check-fluctuating-course yes)
  =>
  (retract ?f)
  (bind ?question "证据表明这种紊乱有一种以上的病因（如物质和一般躯体疾病）。(yes/no)?")
  (assert (check-etiological-evidence (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::delirium ""
  ?f <- (check-etiological-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由多种病因所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-delirium ""
  ?f <- (check-etiological-evidence no)
  =>
  (retract ?f)
  (bind ?question "由药物使用导致的谵妄。(yes/no)?")
  (assert (check-substance-use-delirium (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-delirium ""
  ?f <- (check-substance-use-delirium yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "药物所致的谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-withdrawal-delirium ""
  ?f <- (check-substance-use-delirium no)
  =>
  (retract ?f)
  (bind ?question "谵妄在物质戒断期间出现。(yes/no)?")
  (assert (check-substance-withdrawal-delirium (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-withdrawal-delirium ""
  ?f <- (check-substance-withdrawal-delirium yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质戒断性谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::substance-intoxication-delirium ""
  ?f <- (check-substance-withdrawal-delirium no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-neurocognitive-symptoms ""
  ?f <- (check-fluctuating-course no)
  =>
  (retract ?f)
  (bind ?question "与以下一个或更多认知领域下降的证据有关：复杂注意、执行功能、学习和记忆、语言、知觉运动或社会认知。(yes/no)?")
  (assert (check-neurocognitive-symptoms (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::check-etiological-evidence-2 ""
  ?f <- (check-neurocognitive-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "证据表明这种紊乱有一种以上的病因（如物质和一般躯体疾病）。(yes/no)?")
  (assert (check-etiological-evidence-2 (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::neurocognitive-disorder ""
  ?f <- (check-etiological-evidence-2 yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于多种病因所致的重度或轻度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-neurocognitive-disorder ""
  ?f <- (check-etiological-evidence-2 no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的重度或轻度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-hallucinogenic-persistent-perception-disorder ""
  ?f <- (check-neurocognitive-symptoms no)
  =>
  (retract ?f)
  (bind ?question "再次经历致幻剂中毒期间所体验到的知觉症状。(yes/no)?")
  (assert (check-hallucinogenic-persistent-perception-disorder (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::hallucinogenic-persistent-perception-disorder ""
  ?f <- (check-hallucinogenic-persistent-perception-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "致幻剂持续性知觉障碍"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-psychotic-disorder ""
  ?f <- (check-hallucinogenic-persistent-perception-disorder no)
  =>
  (retract ?f)
  (bind ?question "妄想或幻觉是主要临床表现并严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-psychotic-disorder (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-psychotic-disorder ""
  ?f <- (check-substance-use-psychotic-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的精神病性障碍（标注是否于中毒或戒断期间起病）。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-bipolar-disorder ""
  ?f <- (check-substance-use-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "高涨、膨胀/易激惹的心境是主要临床表现并严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-bipolar-disorder (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-bipolar-disorder ""
  ?f <- (check-substance-use-bipolar-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的双相及相关障碍（标注是否于中毒或戒断期间起病）。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-depressive-disorder ""
  ?f <- (check-substance-use-bipolar-disorder no)
  =>
  (retract ?f)
  (bind ?question "抑郁心境/显著下降的兴趣或愉悦感是主要临床表现并严重的需要临床关注。(yes/no)?")
  (assert (check-substance-use-depressive-disorder (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-depressive-disorder ""
  ?f <- (check-substance-use-depressive-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的抑郁障碍（标注是否于中毒或戒断期间起病）。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-anxiety-disorder ""
  ?f <- (check-substance-use-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "焦虑/惊恐发作是主要临床表现并严重的需要临床关注。(yes/no)?")
  (assert (check-substance-use-anxiety-disorder (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-anxiety-disorder ""
  ?f <- (check-substance-use-anxiety-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的焦虑障碍（标注是否于中毒或戒断期间，或药物使用后起病）。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-OCD ""
  ?f <- (check-substance-use-anxiety-disorder no)
  =>
  (retract ?f)
  (bind ?question "强迫思维、强迫行为、皮肤搔抓、拔毛发、其他聚焦于躯体的重复行为，或强迫及相关障碍的其他典型症状是主要临床表现并严重到需要临床关注。(yes/no)?")
  (assert (check-substance-use-OCD (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-OCD ""
  ?f <- (check-substance-use-OCD yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的强迫及相关障碍（标注是否于中毒或戒断期间，或药物使用后起病）。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-sexual-dysfunction ""
  ?f <- (check-substance-use-OCD no)
  =>
  (retract ?f)
  (bind ?question "有临床意义的性功能失调是主要临床表现并严重的需要临床关注。(yes/no)?")
  (assert (check-substance-use-sexual-dysfunction (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-sexual-dysfunction ""
  ?f <- (check-substance-use-sexual-dysfunction yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的性功能失调（标注是否于中毒或戒断期间，或药物使用后起病）。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-use-sleep-disorder ""
  ?f <- (check-substance-use-sexual-dysfunction no)
  =>
  (retract ?f)
  (bind ?question "突出且严重的失眠紊乱是主要临床表现并严重的需要临床关注。(yes/no)?")
  (assert (check-substance-use-sleep-disorder (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-use-sleep-disorder ""
  ?f <- (check-substance-use-sleep-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的睡眠障碍（标注是否于中毒或撤药/或戒断期间起病）。"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-intoxication ""
  ?f <- (check-substance-use-sleep-disorder no)
  =>
  (retract ?f)
  (bind ?question "在物质使用期间出现的有临床意义的有问题的行为或心理改变。(yes/no)?")
  (assert (check-substance-intoxication (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-intoxication ""
  ?f <- (check-substance-intoxication yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-substance-withdrawal ""
  ?f <- (check-substance-intoxication no)
  =>
  (retract ?f)
  (bind ?question "由于减少或中断物质使用所致的综合征。(yes/no)?")
  (assert (check-substance-withdrawal (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::substance-withdrawal ""
  ?f <- (check-substance-withdrawal yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质戒断"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::check-dysfunction ""
  ?f <- (check-substance-withdrawal no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的物质所致的有临床意义的症状。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule EXCESSIVE-SUBTANCE-USE::unspecific-substance-use-disorder ""
  ?f <- (check-dysfunction yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "未特定的物质相关障碍"))
  (extract-ordered-facts)
  (halt))

(defrule EXCESSIVE-SUBTANCE-USE::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "不是物质所致的障碍（物质所致的症状无临床意义）。"))
  (extract-ordered-facts)
  (halt))


;;;***************************
;;;* cc27: MEMORY-LOSS RULES *
;;;***************************
(defrule MEMORY-LOSS::subsystem-banner ""
  (chief-complaint "记忆丧失")
  =>
  (println "用于记忆丧失的决策树" crlf)
  (assert (check substance-use)))

(defrule MEMORY-LOSS::check-substance-use ""
  ?f <- (check substance-use)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::check-fluctuating-course ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-fluctuating-course (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::substance-use-delirium ""
  ?f <- (check-fluctuating-course yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄，物质戒断性谵妄，药物所致的谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::check-memory-loss-impairment ""
  ?f <- (check-fluctuating-course no)
  =>
  (retract ?f)
  (bind ?question "记忆丧失是主要临床表现并严重到需要临床关注。(yes/no)?")
  (assert (check-memory-loss-impairment (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::substance-use-neurocognitive-disorder ""
  ?f <- (check-memory-loss-impairment yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的重度或轻度神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::substance-intoxication-withdrawal ""
  ?f <- (check-memory-loss-impairment no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断，其他的药物不良反应。"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::check-fluctuating-course-2 ""
  ?f <- (check-medical-conditions yes)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-fluctuating-course-2 (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::medical-conditions-delirium ""
  ?f <- (check-fluctuating-course-2 yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::medical-conditions-neurocognitive-disorder ""
  ?f <- (check-fluctuating-course-2 no) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度或轻度神经认知障碍。为了区分轻度和重度神经认知障碍及确定病因类型，参见用于鉴别诊断的认知损害树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::check-dissociative-identity-disorder ""
  ?f <- (check-medical-conditions no)
  =>
  (retract ?f)
  (bind ?question "存在以两个或更多不同的人格状态为特征的身份瓦解。(yes/no)?")
  (assert (check-dissociative-identity-disorder (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::dissociative-identity-disorder ""
  ?f <- (check-dissociative-identity-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "分离性身份障碍"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::check-traumatic-events ""
  ?f <- (check-dissociative-identity-disorder no)
  =>
  (retract ?f)
  (bind ?question "对极端创伤性事件的记忆丧失。(yes/no)?")
  (assert (check-traumatic-events (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::check-traumatic-symptoms ""
  ?f <- (check-traumatic-events yes)
  =>
  (retract ?f)
  (bind ?question "存在侵入症状、回避与事件有关的刺激、认知和心境的负性改变以及警觉性和活动的改变。(yes/no)?")
  (assert (check-traumatic-symptoms (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::check-course ""
  ?f <- (check-traumatic-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "病程超过1个月。(yes/no)?")
  (assert (check-course (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::PTSD ""
  ?f <- (check-course yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "创伤后应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::acute-stress-disorder ""
  ?f <- (check-course no) 
  =>
  (retract ?f)  
  (assert (diagnosis "急性应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::check-dissociative-amnesia ""
  (or (check-traumatic-events no)
      (check-traumatic-symptoms no))
  =>
  (bind ?question "对其他个人信息的记忆丧失，与普通的健忘不一致。(yes/no)?")
  (assert (check-dissociative-amnesia (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::dissociative-amnesia ""
  ?f <- (check-dissociative-amnesia yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "分离性健忘症"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::check-fake-memory-loss ""
  ?f <- (check-dissociative-amnesia no)
  =>
  (retract ?f)
  (bind ?question "伪装的记忆丧失或损害。(yes/no)?")
  (assert (check-fake-memory-loss (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::check-facticious-disorder ""
  ?f <- (check-fake-memory-loss yes)
  =>
  (retract ?f)
  (bind ?question "在没有明显的外部奖赏时，欺骗行为也是显而易见的。(yes/no)?")
  (assert (check-facticious-disorder (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::facticious-disorder ""
  ?f <- (check-facticious-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "做作性障碍"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::malinger ""
  ?f <- (check-facticious-disorder no) 
  =>
  (retract ?f)  
  (assert (diagnosis "诈病"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::check-major-depressive-disorder ""
  ?f <- (check-fake-memory-loss no)
  =>
  (retract ?f)
  (bind ?question "作为重性抑郁发作（“假性痴呆”）的有关特征出现。(yes/no)?")
  (assert (check-major-depressive-disorder (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::major-depressive-disorder ""
  ?f <- (check-major-depressive-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "在重性抑郁障碍、双相I型障碍或双相II型障碍或分裂情感性障碍中的重性抑郁发作。"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::check-aging-process ""
  ?f <- (check-major-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "伴随衰老的进程出现但鉴于个体的年龄，仍在正常范围。(yes/no)?")
  (assert (check-aging-process (yes-or-no-p ?question))))

(defrule MEMORY-LOSS::aging-process ""
  ?f <- (check-aging-process yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "与衰老有关的认知下降。"))
  (extract-ordered-facts)
  (halt))

(defrule MEMORY-LOSS::final ""
  ?f <- (check-aging-process no) 
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”健忘"))
  (extract-ordered-facts)
  (halt))

;;;************************************
;;;* cc28: COGNITIVE-IMPAIRMENT RULES *
;;;************************************
(defrule COGNITIVE-IMPAIRMENT::subsystem-banner ""
  (chief-complaint "认知损害")
  =>
  (println "用于认知损害的决策树" crlf)
  (assert (check memory-loss)))

(defrule COGNITIVE-IMPAIRMENT::check-memory-loss ""
  ?f <- (check memory-loss)
  =>
  (retract ?f)
  (bind ?question "仅有记忆丧失。(yes/no)?")
  (assert (check-memory-loss (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::memory-loss ""
  ?f <- (check-memory-loss yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "参见用于鉴别诊断的记忆丧失树形图。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-fluctuating-course ""
  ?f <- (check-memory-loss no)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-fluctuating-course (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-etiological-evidence ""
  ?f <- (check-fluctuating-course yes)
  =>
  (retract ?f)
  (bind ?question "证据表明谵妄有一种以上的病因（如一种以上作为病因的一般躯体疾病，一般躯体疾病和物质中毒）。(yes/no)?")
  (assert (check-etiological-evidence (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::delirium ""
  ?f <- (check-etiological-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由多种病因所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-substance-use ""
  ?f <- (check-etiological-evidence no)
  =>
  (retract ?f)
  (bind ?question "由于某种物质（包括药物）的生理效应所致。(yes/no)?")
  (assert (check-substance-use (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-substance-use-delirium ""
  ?f <- (check-substance-use yes)
  =>
  (retract ?f)
  (bind ?question "由药物使用导致的谵妄。(yes/no)?")
  (assert (check-substance-use-delirium (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::substance-use-delirium ""
  ?f <- (check-substance-use-delirium yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "药物所致的谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-substance-withdrawal-delirium ""
  ?f <- (check-substance-use-delirium no)
  =>
  (retract ?f)
  (bind ?question "谵妄在物质戒断期间出现。(yes/no)?")
  (assert (check-substance-withdrawal-delirium (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::substance-withdrawal-delirium ""
  ?f <- (check-substance-withdrawal-delirium yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质戒断性谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::substance-intoxication-delirium ""
  ?f <- (check-substance-withdrawal-delirium no) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒性谵妄"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-medical-conditions ""
  ?f <- (check-substance-use no)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病的生理效应所致。(yes/no)?")
  (assert (check-medical-conditions (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::medical-conditions-delirium ""
  ?f <- (check-medical-conditions yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::specific-unspecific-delirium ""
  ?f <- (check-medical-conditions no) 
  =>
  (retract ?f)  
  (assert (diagnosis "其他特定的或未特定的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-psychotic-disturbance ""
  ?f <- (check-fluctuating-course no)
  =>
  (retract ?f)
  (bind ?question "发生在精神病性紊乱持续至少1个月的背景下，特征是存在活跃期症状（即妄想、幻觉、言语瓦解、明显瓦解的或紧张症行为、阴性症状）及前驱期或残留期。(yes/no)?")
  (assert (check-psychotic-disturbance (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-cognitive-symptoms ""
  ?f <- (check-psychotic-disturbance yes)
  =>
  (retract ?f)
  (bind ?question "认知症状（如陈述性记忆和工作记忆、语言功能和其他执行功能的减退）可以完全用精神病性障碍来解释。(yes/no)?")
  (assert (check-cognitive-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-cognitive-symptoms-course ""
  ?f <- (check-cognitive-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "病程为6个月或以上。(yes/no)?")
  (assert (check-cognitive-symptoms-course (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::schizophrenia ""
  ?f <- (check-cognitive-symptoms-course yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::schizophreniform ""
  ?f <- (check-cognitive-symptoms-course no) 
  =>
  (retract ?f)  
  (assert (diagnosis "精神分裂症样障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-bipolar-disorder ""
  (or (check-psychotic-disturbance no)
      (check-cognitive-symptoms no))
  =>
  (bind ?question "发生在反复的躁狂发作和重性抑郁发作的背景下。(yes/no)?")
  (assert (check-bipolar-disorder (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-bipolar-cognitive-symptoms ""
  ?f <- (check-bipolar-disorder yes)
  =>
  (retract ?f)
  (bind ?question "认知症状完全可以解释为双相I型障碍的有关特征。(yes/no)?")
  (assert (check-bipolar-cognitive-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::bipolar-I-disorder ""
  ?f <- (check-bipolar-cognitive-symptoms yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "双相I型障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-major-depressive-disorder ""
  (or (check-bipolar-disorder no)
      (check-bipolar-cognitive-symptoms no))
  =>
  (bind ?question "发生在一次抑郁心境发作或者兴趣或愉悦感减退的背景下，伴有特征性的抑郁症状。(yes/no)?")
  (assert (check-major-depressive-disorder (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-major-depressive-cognitive-symptoms ""
  ?f <- (check-major-depressive-disorder yes)
  =>
  (retract ?f)
  (bind ?question "认知症状（即思考或集中注意力的能力减退）完全可以用重性抑郁发作来解释。(yes/no)?")
  (assert (check-major-depressive-cognitive-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::major-depressive-disorder ""
  ?f <- (check-major-depressive-cognitive-symptoms yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "在重性抑郁障碍、双相I型障碍或双相II型障碍或分裂情感性障碍中的重性抑郁发作。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-persistent-depressive-disorder ""
  (or (check-major-depressive-disorder no)
      (check-major-depressive-cognitive-symptoms no))
  =>
  (bind ?question "在至少2年的多数日子里，抑郁心境持续存在。(yes/no)?")
  (assert (check-persistent-depressive-disorder (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-persistent-depressive-cognitive-symptoms ""
  ?f <- (check-persistent-depressive-disorder yes)
  =>
  (retract ?f)
  (bind ?question "认知症状（即思考或集中注意力的能力减退）完全可以用持续性抑郁障碍来解释。(yes/no)?")
  (assert (check-persistent-depressive-cognitive-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::persistent-depressive-disorder ""
  ?f <- (check-persistent-depressive-cognitive-symptoms yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "持续性抑郁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-premenstrual-dysphoric-disorder ""
  (or (check-persistent-depressive-disorder no)
      (check-persistent-depressive-cognitive-symptoms no))
  =>
  (bind ?question "周期性的烦躁心境在月经开始前1周出现并在月经结束后1周消失。(yes/no)?")
  (assert (check-premenstrual-dysphoric-disorder (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-premenstrual-dysphoric-cognitive-symptoms ""
  ?f <- (check-premenstrual-dysphoric-disorder yes)
  =>
  (retract ?f)
  (bind ?question "认知症状（即思考或集中注意力的能力减退）完全可以用经前期烦躁障碍来解释。(yes/no)?")
  (assert (check-premenstrual-dysphoric-cognitive-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::premenstrual-dysphoric-disorder ""
  ?f <- (check-premenstrual-dysphoric-cognitive-symptoms yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "经前期烦躁障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-ADHD ""
  (or (check-premenstrual-dysphoric-disorder no)
      (check-premenstrual-dysphoric-cognitive-symptoms no))
  =>
  (bind ?question "伴有干扰功能的其他注意力不集中和/或多动/冲动症状，存在于至少两个场合中，起病于12岁之前。(yes/no)?")
  (assert (check-ADHD (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-ADHD-cognitive-symptoms ""
  ?f <- (check-ADHD yes)
  =>
  (retract ?f)
  (bind ?question "认知症状（即思考或集中注意力的能力减退）完全可以用注意缺陷/多动障碍来解释。(yes/no)?")
  (assert (check-ADHD-cognitive-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::ADHD ""
  ?f <- (check-ADHD-cognitive-symptoms yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "注意缺陷/多动障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-stress-disorder ""
  (or (check-ADHD no)
      (check-ADHD-cognitive-symptoms no))
  =>
  (bind ?question "发生在对创伤性应激源做出反应的背景下，伴有侵入症状、回避与创伤有关的刺激、认知和心境的负性改变以及警觉性和反应性的改变。(yes/no)?")
  (assert (check-stress-disorder (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-stress-cognitive-symptoms ""
  ?f <- (check-stress-disorder yes)
  =>
  (retract ?f)
  (bind ?question "认知症状（即思考或集中注意力的能力减退）完全可以用创伤性应激障碍来解释。(yes/no)?")
  (assert (check-stress-cognitive-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::stress-disorder ""
  ?f <- (check-stress-cognitive-symptoms yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "创伤后应激障碍或急性应激障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-generalized-anxiety-disorder ""
  (or (check-stress-disorder no)
      (check-stress-cognitive-symptoms no))
  =>
  (bind ?question "发生在对很多事件或情境过度焦虑和担心的背景下，持续至少6个月。(yes/no)?")
  (assert (check-generalized-anxiety-disorder (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-generalized-anxiety-cognitive-symptoms ""
  ?f <- (check-generalized-anxiety-disorder yes)
  =>
  (retract ?f)
  (bind ?question "认知症状（即思考或集中注意力的能力减退）完全可以用广泛性焦虑障碍来解释。(yes/no)?")
  (assert (check-generalized-anxiety-cognitive-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::generalized-anxiety-disorder ""
  ?f <- (check-generalized-anxiety-cognitive-symptoms yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "广泛性焦虑障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-intellectual-disability ""
  (or (check-generalized-anxiety-disorder no)
      (check-generalized-anxiety-cognitive-symptoms no))
  =>
  (bind ?question "起病于发育期并在概念、社交和实用领域存在智力及适应功能的缺陷。(yes/no)?")
  (assert (check-intellectual-disability (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-global-developmental-delay ""
  ?f <- (check-intellectual-disability yes)
  =>
  (retract ?f)
  (bind ?question "无法接受系统的智力评估。(yes/no)?")
  (assert (check-global-developmental-delay (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::global-developmental-delay ""
  ?f <- (check-global-developmental-delay yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "全面发育迟缓"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-intellectual-disability-symptoms ""
  ?f <- (check-global-developmental-delay no)
  =>
  (retract ?f)
  (bind ?question "存在智力功能缺陷（使用临床评估和标准化测验确认）和随之出现的适应功能缺陷，起病于发育期。(yes/no)?")
  (assert (check-intellectual-disability-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-intellectual-development-disorder ""
  ?f <- (check-intellectual-disability-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "丧失先前习得的认知技能，如在严重创伤性脑损伤中那样。(yes/no)?")
  (assert (check-intellectual-development-disorder (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::intellectual-development-disorder ""
  ?f <- (check-intellectual-development-disorder no) 
  =>
  (retract ?f)  
  (assert (diagnosis "智力障碍（智力发育障碍）"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-neuropsychological-impairment ""
  (or (check-intellectual-disability no)
      (check-intellectual-disability-symptoms no)
      (check-intellectual-development-disorder yes))
  =>
  (bind ?question "神经心理测验或其他量化评估证实存在显著的损害，并且这些缺陷干扰了个体日常生活的独立性。(yes/no)?")
  (assert (check-neuropsychological-impairment (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-neurocognitive-decrement ""
  ?f <- (check-neuropsychological-impairment no)
  =>
  (retract ?f)
  (bind ?question "与已经证实的表现水平相比，存在一定的认知下降，并伴有一定的认知表现损害，但尚未干扰日常活动的独立性。(yes/no)?")
  (assert (check-neurocognitive-decrement (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-somatic-disease-neurocognitive-decrement ""
  ?f <- (check-neurocognitive-decrement yes)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病的直接效应所致。(yes/no)?")
  (assert (check-somatic-disease-neurocognitive-decrement (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::somatic-disease-neurocognitive-decrement ""
  ?f <- (check-somatic-disease-neurocognitive-decrement yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的轻度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-substance-use-neurocognitive-decrement ""
  ?f <- (check-somatic-disease-neurocognitive-decrement no)
  =>
  (retract ?f)
  (bind ?question "由某种物质的生理效应导致，持续时间超过物质中毒或物质戒断的通常病程。(yes/no)?")
  (assert (check-substance-use-neurocognitive-decrement (yes-or-no-p ?question))))


(defrule COGNITIVE-IMPAIRMENT::substance-use-neurocognitive-decrement ""
  ?f <- (check-substance-use-neurocognitive-decrement yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的轻度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-intoxication-withdrawal ""
  ?f <- (check-neurocognitive-decrement no)
  =>
  (retract ?f)
  (bind ?question "由某种物质的直接生理效应导致。(yes/no)?")
  (assert (check-intoxication-withdrawal (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::substance-intoxication-withdrawal ""
  ?f <- (check-intoxication-withdrawal yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质中毒，物质戒断。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-dysfunction ""
  ?f <- (check-intoxication-withdrawal no)
  =>
  (retract ?f)
  (bind ?question "有临床意义的认知损害代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "“正常的”认知损害（如健忘）。"))
  (extract-ordered-facts)
  (halt))

;;;=================================
;;; major neurocognitive impairment 
;;;=================================

(defrule COGNITIVE-IMPAIRMENT::check-etiological-disturbance ""
  ?f <- (check-neuropsychological-impairment yes)
  =>
  (retract ?f)
  (bind ?question "证据表明这种紊乱有一种以上的病因（如脑血管病和阿尔茨海默病）。(yes/no)?")
  (assert (check-etiological-disturbance (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::etiological-major-neurocognitive-disorder ""
  ?f <- (check-etiological-disturbance yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于多种病因所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-etiological-Parkinson ""
  ?f <- (check-etiological-disturbance no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病并且损害逐渐进展，出现在已确诊的帕金森病中。(yes/no)?")
  (assert (check-etiological-Parkinson (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-Parkinson ""
  ?f <- (check-etiological-Parkinson yes)
  =>
  (retract ?f)
  (bind ?question "没有证据表明存在混合性病因，并且帕金森病明确发生在神经认知障碍起病前。(yes/no)?")
  (assert (check-Parkinson (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::Parkinson ""
  ?f <- (check-Parkinson yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能由于帕金森病所致的重度神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::suspected-Parkinson ""
  ?f <- (check-Parkinson no) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑帕金森病所致的重度神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-traumatic-brain-injury ""
  ?f <- (check-etiological-Parkinson no)
  =>
  (retract ?f)
  (bind ?question "症状出现在创伤性脑损伤后，并经过急性的损伤后阶段，症状仍持续存在。(yes/no)?")
  (assert (check-traumatic-brain-injury (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::traumatic-brain-injury ""
  ?f <- (check-traumatic-brain-injury yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于创伤性脑损伤所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-HIV ""
  ?f <- (check-traumatic-brain-injury no)
  =>
  (retract ?f)
  (bind ?question "经证实感染HIV并且不能用继发性脑病如疱疹性脑炎或隐球菌病来解释。(yes/no)?")
  (assert (check-HIV (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::HIV ""
  ?f <- (check-HIV yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于HIV感染所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-Huntington ""
  ?f <- (check-HIV no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，逐渐进展，并有证据表明症状是亨廷顿氏病的直接后果。(yes/no)?")
  (assert (check-Huntington (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::Huntington ""
  ?f <- (check-Huntington yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于亨廷顿氏病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-prion ""
  ?f <- (check-Huntington no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，快速进展，并有朊病毒病的生物标记物证据。(yes/no)?")
  (assert (check-prion (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::prion ""
  ?f <- (check-prion yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于朊病毒病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-frontotemporal-impairment-symptoms ""
  ?f <- (check-prion no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，逐渐进展，并有行为症状（如脱抑制、情感淡漠、缺乏共情、强迫行为、口欲亢进）或语言能力的显著下降；相对保留了学习、记忆和知觉运动的功能。(yes/no)?")
  (assert (check-frontotemporal-impairment-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-frontotemporal-impairment-evidence ""
  ?f <- (check-frontotemporal-impairment-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "额颞叶神经认知障碍致病基因突变或神经影像中发现不成比例的额叶或颞叶受损的证据。(yes/no)?")
  (assert (check-frontotemporal-impairment-evidence (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::possible-frontotemporal-neurocognitive-disorder ""
  ?f <- (check-frontotemporal-impairment-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能的额颞叶神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::suspected-frontotemporal-neurocognitive-disorder ""
  ?f <- (check-frontotemporal-impairment-evidence no) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑的额颞叶神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-lewy-body-disease-symptoms ""
  ?f <- (check-frontotemporal-impairment-symptoms no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，逐渐进展，伴有以下任何一种表现：（1）波动性认知功能，伴注意力和警觉性的显著变化；（2）反复出现完整且详尽的视幻觉；（3）在认知下降后自发出现帕金森氏综合征的特征表现；（4）快速眼动睡眠行为障碍；（5）或严重的神经阻滞剂敏感。(yes/no)?")
  (assert (check-lewy-body-disease-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-lewy-body-disease-evidence ""
  ?f <- (check-lewy-body-disease-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "有以下核心特征中的两个：（1）波动性认知功能，（2）视幻觉，（3）在认知下降后自发出现帕金森氏综合征的特征表现。或者一个核心特征和快速眼动睡眠行为障碍或严重的神经阻滞剂敏感。(yes/no)?")
  (assert (check-lewy-body-disease-evidence (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::possible-major-neurocognitive-disorder-lewy-body-disease ""
  ?f <- (check-lewy-body-disease-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能的重度神经认知障碍伴路易体病。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::suspected-major-neurocognitive-disorder-lewy-body-disease ""
  ?f <- (check-lewy-body-disease-evidence no) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑的重度神经认知障碍伴路易体病。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-vascular-symptoms ""
  ?f <- (check-lewy-body-disease-symptoms no)
  =>
  (retract ?f)
  (bind ?question "存在着脑血管病以及与血管性病因相一致的特征（如认知缺陷的起病与血管事件相关或有证据显示复杂注意和额叶执行功能显著下降）。(yes/no)?")
  (assert (check-vascular-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-vascular-evidence ""
  ?f <- (check-vascular-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "神经影像学支持脑实质的损伤是由于脑血管病所致，神经认知综合征在时间上与有记录的脑血管事件相关，或同时存在脑血管病的临床和遗传学证据。(yes/no)?")
  (assert (check-vascular-evidence (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::possible-major-vascular-neurocognitive-disorder ""
  ?f <- (check-vascular-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能的重度血管性神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::suspected-major-vascular-neurocognitive-disorder ""
  ?f <- (check-vascular-evidence no) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑的重度血管性神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-Alzheimer-symptoms ""
  ?f <- (check-vascular-symptoms no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，在至少两个认知领域有逐渐进展的损害。(yes/no)?")
  (assert (check-Alzheimer-symptoms (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::check-Alzheimer-evidence ""
  ?f <- (check-Alzheimer-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "阿尔茨海默病的致病基因突变或下列三项全部存在：记忆和某个其他认知领域下降的明确证据，认知下降稳步进展、无延长的平台期，以及无证据表明存在混合性病因。(yes/no)?")
  (assert (check-Alzheimer-evidence (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::possible-Alzheimer-major-neurocognitive-disorder ""
  ?f <- (check-Alzheimer-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能的由于阿尔茨海默病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::suspected-Alzheimer-major-neurocognitive-disorder ""
  ?f <- (check-Alzheimer-evidence no) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑的由于阿尔茨海默病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-etiological-somatic-disease ""
  ?f <- (check-Alzheimer-symptoms no)
  =>
  (retract ?f)
  (bind ?question "从病史、体格检查或实验室发现获得的证据表明另一种躯体疾病（如多发性硬化症）是症状的病因。(yes/no)?")
  (assert (check-etiological-somatic-disease (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::somatic-disease-major-neurocognitive-disorder ""
  ?f <- (check-etiological-somatic-disease yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::check-etiological-substance-use ""
  ?f <- (check-etiological-somatic-disease no)
  =>
  (retract ?f)
  (bind ?question "由某种物质的生理效应导致，持续时间超过物质中毒或物质戒断的通常病程。(yes/no)?")
  (assert (check-etiological-substance-use (yes-or-no-p ?question))))

(defrule COGNITIVE-IMPAIRMENT::substance-use-major-neurocognitive-disorder ""
  ?f <- (check-etiological-substance-use yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "物质/药物所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule COGNITIVE-IMPAIRMENT::unspecific-neurocognitive-disorder ""
  (or (check-substance-use-neurocognitive-decrement no)
      (check-dysfunction yes)
      (check-etiological-substance-use no))
  =>
  (assert (diagnosis "未特定的神经认知障碍。"))
  (extract-ordered-facts)
  (halt))


;;;**********************************
;;;* cc29: MEDICAL-CONDITIONS RULES *
;;;**********************************
(defrule MEDICAL-CONDITIONS::subsystem-banner ""
  (chief-complaint "躯体疾病作为病因")
  =>
  (println "用于躯体疾病作为病因的决策树" crlf)
  (assert (check fluctuating-course)))

(defrule MEDICAL-CONDITIONS::check-fluctuating-course ""
  ?f <- (check fluctuating-course)
  =>
  (retract ?f)
  (bind ?question "与注意和意识的紊乱有关，以波动性病程为特征。(yes/no)?")
  (assert (check-fluctuating-course (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::check-etiological-evidence ""
  ?f <- (check-fluctuating-course yes)
  =>
  (retract ?f)
  (bind ?question "证据表明谵妄有一种以上的病因（如一种以上作为病因的一般躯体疾病，一般躯体疾病和物质中毒）。(yes/no)?")
  (assert (check-etiological-evidence (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::delirium ""
  ?f <- (check-etiological-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由多种病因所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::medical-conditions-delirium ""
  ?f <- (check-etiological-evidence no) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的谵妄。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-neurocognitive-symptoms ""
  ?f <- (check-fluctuating-course no)
  =>
  (retract ?f)
  (bind ?question "有一个或更多认知领域（复杂注意、执行功能、学习和记忆、语言、知觉运动以及社交认知）显著受损的证据，最好通过神经心理测验或其他量化的评估来证实，同时这些缺陷干扰到了个体日常生活的独立性。(yes/no)?")
  (assert (check-neurocognitive-symptoms (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::check-etiological-major-neurocognitive-disorder ""
  ?f <- (check-neurocognitive-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "证据表明这种紊乱有一种以上的病因（如脑血管病和阿尔茨海默病）。(yes/no)?")
  (assert (check-etiological-major-neurocognitive-disorder (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::etiological-major-neurocognitive-disorder ""
  ?f <- (check-etiological-major-neurocognitive-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于多种病因所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-etiological-Parkinson ""
  ?f <- (check-etiological-major-neurocognitive-disorder no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病并且损害逐渐进展，出现在已确诊的帕金森病中。(yes/no)?")
  (assert (check-etiological-Parkinson (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::check-Parkinson ""
  ?f <- (check-etiological-Parkinson yes)
  =>
  (retract ?f)
  (bind ?question "没有证据表明存在混合性病因，并且帕金森病明确发生在神经认知障碍起病前。(yes/no)?")
  (assert (check-Parkinson (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::possible-Parkinson-major-neurocognitive-disorder ""
  ?f <- (check-Parkinson yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能由于帕金森病所致的重度神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::suspected-Parkinson-major-neurocognitive-disorder ""
  ?f <- (check-Parkinson no) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑帕金森病所致的重度神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-traumatic-brain-injury ""
  ?f <- (check-etiological-Parkinson no)
  =>
  (retract ?f)
  (bind ?question "症状出现在创伤性脑损伤后，并经过急性的损伤后阶段，症状仍持续存在。(yes/no)?")
  (assert (check-traumatic-brain-injury (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::traumatic-brain-injury-major-neurocognitive-disorder ""
  ?f <- (check-traumatic-brain-injury yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于创伤性脑损伤所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-HIV ""
  ?f <- (check-traumatic-brain-injury no)
  =>
  (retract ?f)
  (bind ?question "经证实感染HIV并且不能用继发性脑病如疱疹性脑炎或隐球菌病来解释。(yes/no)?")
  (assert (check-HIV (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::HIV-major-neurocognitive-disorder ""
  ?f <- (check-HIV yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于HIV感染所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-Huntington ""
  ?f <- (check-HIV no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，逐渐进展，并有证据表明症状是亨廷顿氏病的直接后果。(yes/no)?")
  (assert (check-Huntington (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::Huntington-major-neurocognitive-disorder ""
  ?f <- (check-Huntington yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于亨廷顿氏病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-prion ""
  ?f <- (check-Huntington no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，快速进展，并有朊病毒病的生物标记物证据。(yes/no)?")
  (assert (check-prion (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::prion-major-neurocognitive-disorder ""
  ?f <- (check-prion yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于朊病毒病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-frontotemporal-symptoms ""
  ?f <- (check-prion no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，逐渐进展，并有行为症状（如脱抑制、情感淡漠、缺乏共情、强迫行为、口欲亢进）或语言能力的显著下降；相对保留了学习、记忆和知觉运动的功能。(yes/no)?")
  (assert (check-frontotemporal-symptoms (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::check-frontotemporal-evidence ""
  ?f <- (check-frontotemporal-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "额颞叶神经认知障碍致病基因突变或神经影像中发现不成比例的额叶或颞叶受损的证据。(yes/no)?")
  (assert (check-frontotemporal-evidence (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::possible-frontotemporal-major-neurocognitive-disorder ""
  ?f <- (check-frontotemporal-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能的额颞叶神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::suspected-frontotemporal-major-neurocognitive-disorder ""
  ?f <- (check-frontotemporal-evidence no) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑的额颞叶神经认知障碍"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-lewy-body-disease-symptoms ""
  ?f <- (check-frontotemporal-symptoms no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，逐渐进展，伴有以下任何一种表现：（1）波动性认知功能，伴注意力和警觉性的显著变化；（2）反复出现完整且详尽的视幻觉；（3）在认知下降后自发出现帕金森氏综合征的特征表现；（4）快速眼动睡眠行为障碍；（5）或严重的神经阻滞剂敏感。(yes/no)?")
  (assert (check-lewy-body-disease-symptoms (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::check-lewy-body-disease-evidence ""
  ?f <- (check-lewy-body-disease-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "有以下核心特征中的两个：（1）波动性认知功能，（2）视幻觉，（3）在认知下降后自发出现帕金森氏综合征的特征表现。或者一个核心特征和快速眼动睡眠行为障碍或严重的神经阻滞剂敏感。(yes/no)?")
  (assert (check-lewy-body-disease-evidence (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::possible-lewy-body-disease-major-neurocognitive-disorder ""
  ?f <- (check-lewy-body-disease-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能的重度神经认知障碍伴路易体病。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::suspected-lewy-body-disease-major-neurocognitive-disorder ""
  ?f <- (check-lewy-body-disease-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑的重度神经认知障碍伴路易体病。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-vascular-symptoms ""
  ?f <- (check-lewy-body-disease-symptoms no)
  =>
  (retract ?f)
  (bind ?question "存在着脑血管病以及与血管性病因相一致的特征（如认知缺陷的起病与血管事件相关或有证据显示复杂注意和额叶执行功能显著下降）。(yes/no)?")
  (assert (check-vascular-symptoms (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::check-vascular-evidence ""
  ?f <- (check-vascular-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "神经影像学支持脑实质的损伤是由于脑血管病所致，神经认知综合征在时间上与有记录的脑血管事件相关，或同时存在脑血管病的临床和遗传学证据。(yes/no)?")
  (assert (check-vascular-evidence (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::possible-vascular-major-neurocognitive-disorder ""
  ?f <- (check-vascular-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能的重度血管性神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::suspected-vascular-major-neurocognitive-disorder ""
  ?f <- (check-vascular-evidence no) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑的重度血管性神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-Alzheimer-symptoms ""
  ?f <- (check-vascular-symptoms no)
  =>
  (retract ?f)
  (bind ?question "隐匿起病，在至少两个认知领域有逐渐进展的损害。(yes/no)?")
  (assert (check-Alzheimer-symptoms (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::check-Alzheimer-evidence ""
  ?f <- (check-Alzheimer-symptoms yes)
  =>
  (retract ?f)
  (bind ?question "阿尔茨海默病的致病基因突变或下列三项全部存在：记忆和某个其他认知领域下降的明确证据，认知下降稳步进展、无延长的平台期，以及无证据表明存在混合性病因。(yes/no)?")
  (assert (check-Alzheimer-evidence (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::possible-Alzheimer-major-neurocognitive-disorder ""
  ?f <- (check-Alzheimer-evidence yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "可能的由于阿尔茨海默病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::suspected-Alzheimer-major-neurocognitive-disorder ""
  ?f <- (check-Alzheimer-evidence no) 
  =>
  (retract ?f)  
  (assert (diagnosis "可疑的由于阿尔茨海默病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-somatic-disease ""
  ?f <- (check-Alzheimer-symptoms no)
  =>
  (retract ?f)
  (bind ?question "从病史、体格检查或实验室发现获得的证据表明另一种躯体疾病（如多发性硬化症）是症状的病因。(yes/no)?")
  (assert (check-somatic-disease (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::somatic-disease-major-neurocognitive-disorder ""
  ?f <- (check-somatic-disease yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的重度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-neurocognitive-decrement ""
  ?f <- (check-neurocognitive-symptoms no)
  =>
  (retract ?f)
  (bind ?question "与已经证实的表现水平相比，存在一定的认知下降，并伴有一定的认知表现损害，但尚未干扰日常活动的独立性。(yes/no)?")
  (assert (check-neurocognitive-decrement (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::check-somatic-disease-neurocognitive-decrement ""
  ?f <- (check-neurocognitive-decrement yes)
  =>
  (retract ?f)
  (bind ?question "由于某种一般躯体疾病的直接效应所致。(yes/no)?")
  (assert (check-somatic-disease-neurocognitive-decrement (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::somatic-disease-neurocognitive-disorder ""
  ?f <- (check-somatic-disease-neurocognitive-decrement yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的轻度神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::unspecific-neurocognitive-disorder ""
  (or (check-somatic-disease no)
      (check-somatic-disease-neurocognitive-decrement no))
  =>
  (assert (diagnosis "未特定的神经认知障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-psychotic-disorder ""
  ?f <- (check-neurocognitive-decrement no)
  =>
  (retract ?f)
  (bind ?question "突出的妄想或幻觉占主导。(yes/no)?")
  (assert (check-psychotic-disorder (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::psychotic-disorder ""
  ?f <- (check-psychotic-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的精神病性障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-bipolar-disorder ""
  ?f <- (check-psychotic-disorder no)
  =>
  (retract ?f)
  (bind ?question "突出且持续异常的心境高涨、膨胀和/或易激惹和异常增加的活动或精力占主导。(yes/no)?")
  (assert (check-bipolar-disorder (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::bipolar-disorder ""
  ?f <- (check-bipolar-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的双相及相关障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-depressive-disorder ""
  ?f <- (check-bipolar-disorder no)
  =>
  (retract ?f)
  (bind ?question "突出且持续的抑郁心境或者兴趣或愉悦感的明显减退占主导。(yes/no)?")
  (assert (check-depressive-disorder (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::depressive-disorder ""
  ?f <- (check-depressive-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的抑郁障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-anxiety-disorder ""
  ?f <- (check-depressive-disorder no)
  =>
  (retract ?f)
  (bind ?question "突出的惊恐发作或焦虑。(yes/no)?")
  (assert (check-anxiety-disorder (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::anxiety-disorder ""
  ?f <- (check-anxiety-disorder yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的焦虑障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-OCD ""
  ?f <- (check-anxiety-disorder no)
  =>
  (retract ?f)
  (bind ?question "突出的强迫思维、强迫行为、对外貌的先占观念、囤积行为、搔抓皮肤、拔毛发，以及其他聚焦于身体的重复行为或强迫及相关障碍的其他典型症状。(yes/no)?")
  (assert (check-OCD (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::OCD ""
  ?f <- (check-OCD yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的强迫及相关障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-catatonia ""
  ?f <- (check-OCD no)
  =>
  (retract ?f)
  (bind ?question "至少有三个紧张症症状：木僵、僵住、蜡样屈曲、缄默、违拗、作态、装相、刻板运动、激越、扮鬼脸、模仿言语或模仿动作。(yes/no)?")
  (assert (check-catatonia (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::catatonia ""
  ?f <- (check-catatonia yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的紧张症障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-personality-change ""
  ?f <- (check-catatonia no)
  =>
  (retract ?f)
  (bind ?question "与先前人格模式相比发生的改变。(yes/no)?")
  (assert (check-personality-change (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::personality-change ""
  ?f <- (check-personality-change yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的人格改变。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::check-dysfunction ""
  ?f <- (check-personality-change no)
  =>
  (retract ?f)
  (bind ?question "上述未涵盖的有临床意义的症状在病因学上与一般躯体疾病相关并代表了个体在心理上或生物学上的功能失调。(yes/no)?")
  (assert (check-dysfunction (yes-or-no-p ?question))))

(defrule MEDICAL-CONDITIONS::specific-psychotic-disorder ""
  ?f <- (check-dysfunction yes) 
  =>
  (retract ?f)  
  (assert (diagnosis "由于其他躯体疾病所致的其他特定的精神障碍。"))
  (extract-ordered-facts)
  (halt))

(defrule MEDICAL-CONDITIONS::final ""
  ?f <- (check-dysfunction no) 
  =>
  (retract ?f)  
  (assert (diagnosis "无精神障碍（症状无临床意义）"))
  (extract-ordered-facts)
  (halt))


;;;**********************
;;;* MAIN STARTUP RULES *
;;;**********************

(defrule MAIN::system-banner ""
  (declare (salience 10))
  =>
  (println "您已经进入了......" crlf)
  (println "DSM-5 Differential Diagnosis (DDD) Expert System")
  (println "DSM-5鉴别诊断专家系统")
  (println "=====================" crlf)
  (println "The DDD expert system diagnoses mental disorder problems of a person.")
  (println "DDD专家系统诊断一个人的精神障碍问题。")
  (println "参考文献：《DSM-5鉴别诊断手册》，Michael B. First，2016年3月，北京大学出版社。")
  (println "Designed by OpenMinds, 2025, CLIPS Version 6.4")
  (println "================================================" crlf)
  (list-chief-complaints)
  (choose-chief-complaint (read)))
